I have a signal, let's say x, with a dimension of 60000x1 and i'm plotting it in time, t.
x = % a 60000x1 signal
fs = 1000;
t = 0:1/fs:(length(x)-1)/1000; % i want to plot the signal in seconds and it's correct
so if i plot(t,x);
it plots my signal in seconds (from 0 to 60s)
question is: How do i plot a specific time interval? (eg from 3 to 5s)
i tried plot(t(3:5),x(3:5));
and it plots x based on its original dimension i guess. so it will work at plot(t(3000:5000),x(3000:5000)
but my x label is incorrect.
Any help will be appreciated! Thank you!!
There are two ways to achieve this. The first one is to define a subset of values:
I = 3000:5000;
plot(t(I), x(I));
The second method is to use the xlim
setting:
plot(t,x);
xlim([3 5]);
which will set the bounds of the plot at 3 and 5 seconds.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.