How can I do this expression

1 visualización (últimos 30 días)
Ede gerlderlands
Ede gerlderlands el 4 de Feb. de 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.

Respuestas (1)

Image Analyst
Image Analyst el 4 de Feb. de 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:');

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by