How can I draw lines between the points of traingle after the final formation. It is a formation control problem I want to make the plot as a moving graph how to make it?
1 回表示 (過去 30 日間)
古いコメントを表示
2 件のコメント
回答 (1 件)
Hiro Yoshino
2022 年 6 月 22 日
If you want to draw the trajectories of the points, then comet would be a good fit.
x = -pi:0.01:pi;
y = sin(3*x) + 0.2*cos(4*x);
comet(x,y)
Run the code above in your Live Editor and it will generate a video of the moving trajectories. This is one of the features implemented in R2021b or later. As long as "comet" is available you can see the moving path.
2 件のコメント
Hiro Yoshino
2022 年 6 月 22 日
How about this?:
% sample data
x0 = (0:0.05:10)';
X = repmat(x0,1,3)
Y = [sin(x0),sin(2*x0),sin(3*x0)]
% animated line
figure;
h1 = animatedline('Color','r');
h2 = animatedline('Color','g');
h3 = animatedline('Color','b');
ax = gca;
axis(ax,[0 10 -1 1])
% Loop & visualize
for k = 1:size(X,1)
addpoints(h1,X(k,1),Y(k,1));
addpoints(h2,X(k,2),Y(k,2));
addpoints(h3,X(k,3),Y(k,3));
drawnow
end
参考
カテゴリ
Help Center および File Exchange で Animation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!