# 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)
VIKRAM REDDY ETTAM on 22 Jun 2022
Commented: Hiro on 22 Jun 2022
##### 2 CommentsShowHide 1 older comment
VIKRAM REDDY ETTAM on 22 Jun 2022
thank you, I have joined the points. how to make the simulation as a moving graph. for proper visualization?

Hiro 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 CommentsShowHide 1 older comment
Hiro on 22 Jun 2022
% sample data
x0 = (0:0.05:10)';
X = repmat(x0,1,3)
X = 201×3
0 0 0 0.0500 0.0500 0.0500 0.1000 0.1000 0.1000 0.1500 0.1500 0.1500 0.2000 0.2000 0.2000 0.2500 0.2500 0.2500 0.3000 0.3000 0.3000 0.3500 0.3500 0.3500 0.4000 0.4000 0.4000 0.4500 0.4500 0.4500
Y = [sin(x0),sin(2*x0),sin(3*x0)]
Y = 201×3
0 0 0 0.0500 0.0998 0.1494 0.0998 0.1987 0.2955 0.1494 0.2955 0.4350 0.1987 0.3894 0.5646 0.2474 0.4794 0.6816 0.2955 0.5646 0.7833 0.3429 0.6442 0.8674 0.3894 0.7174 0.9320 0.4350 0.7833 0.9757
% 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)
drawnow
end

### Categories

Find more on Animation in Help Center and File Exchange

R2021a

### Community Treasure Hunt

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

Start Hunting!