Creating a row of points

1 回表示 (過去 30 日間)
Lucas Carvalho
Lucas Carvalho 2015 年 8 月 24 日
回答済み: Walter Roberson 2015 年 8 月 24 日
Hi guys, I am trying to make an animated plot, where I want to plot a trail/row of points as it follows:
xe1 = (-lm/2)+Vest*t;
for j=1:1:length(t)
if xe1(j)>(2*lm)
xe1(j)=(-lm/2);
end
end
For instance, xe1 indices should change so that xe2 = (-lm/2)+(lm/4)+Vest*t, i.e., xe(i+1) = xe(i)+lm/4.
How can I add this condition to this already existing loop? Thank you!

採用された回答

Walter Roberson
Walter Roberson 2015 年 8 月 24 日
N = 5;
Nt = length(t);
xe = zeros(N, Nt);
xe(1,:) = (-lm/2)+Vest*t;
for K = 1 : N
idx = xe(K,:) > 2*lm;
xe(K,idx) = -lm/2;
if K ~= N
xe(K+1,:) = xe(K,:) + lm/4;
end
end
plot(xe.'); %if you want N lines

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnimation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by