How can I define successive vectors by matlab?

1 Ansicht (letzte 30 Tage)
Ashkan Rigi
Ashkan Rigi am 24 Okt. 2021
Bearbeitet: Image Analyst am 24 Okt. 2021
Here is my code sample:
t=[0,4,8,12,16,20];
y=[0.7,0.9,0.9,0.7,0.3,0];
for i=1:length(t)
u=[t(i) t(i+1) t(i+2)];
v=[y(i) y(i+1) y(i+2)];
i=i+3;
end

Akzeptierte Antwort

Image Analyst
Image Analyst am 24 Okt. 2021
Yes, you get new u and v vectors every time - is that what you mean by successive? By the way you should do it this way:
t = [0,4,8,12,16,20]
y = [0.7,0.9,0.9,0.7,0.3,0]
for k = 1 : 3 : length(t)-2
% Get a new u and v for this iteration:
u = t(k : k+2);
v = y(k : k+2);
% Now do something with u and v....
end

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by