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 view (last 30 days)
Show older comments
2 Comments
Answers (1)
Hiro Yoshino
on 22 Jun 2022
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 Comments
Hiro Yoshino
on 22 Jun 2022
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
See Also
Categories
Find more on Animation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!