Effacer les filtres
Effacer les filtres

How can I do this expression

1 vue (au cours des 30 derniers jours)
Ede gerlderlands
Ede gerlderlands le 4 Fév 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.

Réponses (1)

Image Analyst
Image Analyst le 4 Fév 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:');

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by