How can I define successive vectors by matlab?

1 次查看(过去 30 天)
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

采纳的回答

Image Analyst
Image Analyst 2021-10-24
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

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by