Clear Filters
Clear Filters

How can I do this expression

1 view (last 30 days)
Ede gerlderlands
Ede gerlderlands on 4 Feb 2013
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.

Answers (1)

Image Analyst
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:');

Categories

Find more on Loops and Conditional Statements 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!