How can I do this expression

1 次查看(过去 30 天)
Ede gerlderlands
Ede gerlderlands 2013-2-4
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.

回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by