How can I define successive vectors by matlab?

조회 수: 1 (최근 30일)
Ashkan Rigi
Ashkan Rigi 2021년 10월 24일
편집: Image Analyst 2021년 10월 24일
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