How can I do this expression
1 view (last 30 days)
Show older comments
I have two variables 'u' and 's' which are functions of time. I want to plot these variables for the time range of time>=0 and time<=7. The time range of u and s varies within the datafiles. Here is the abridged script script I tried to do
for ii= length(datafiles);
subplot(2,3,ii)
for time>=0 || time<=7;
plot(u,s,'x:')
end
end
but I couldn't succeed and am new to matlab . Any help is highly appreciated.
0 Comments
Answers (1)
Image Analyst
on 4 Feb 2013
No. You're just plotting the entire array over and over again. Get rid of the "time" for loop and just do
validIndexes = theTimeArray >= 0 & theTimeArray <= 7;
plot(u(validIndexes), s(validIndexes), 'x:');
If your u and s arrays are sampled exactly every second, then you could plot those 8 elements (0, 1, 2, 3, 4, 5, 6, 7) like this:
plot(u(1:8), s(1:8), 'x:');
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!