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 天)
显示 更早的评论
回答(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
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!