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?

2 vues (au cours des 30 derniers jours)
  2 commentaires
VIKRAM REDDY ETTAM
VIKRAM REDDY ETTAM le 22 Juin 2022
thank you, I have joined the points. how to make the simulation as a moving graph. for proper visualization?

Connectez-vous pour commenter.

Réponses (1)

Hiro Yoshino
Hiro Yoshino le 22 Juin 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 commentaires
VIKRAM REDDY ETTAM
VIKRAM REDDY ETTAM le 22 Juin 2022
here the above given plot by me is between x and y. each x and y are matrices of size [20000*6]. how to obtain the video of moving trajectories in my case like for each agent?
Hiro Yoshino
Hiro Yoshino le 22 Juin 2022
How about this?:
% 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)
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

Connectez-vous pour commenter.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by