Making a video showing trajectories of particles
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have some X, Y and T (time) co-ordinates for my particles (attached) and I want to plot and make a video of all of my particle trajectories on an X Y axis showing thier respective "motion" through time. Is there a way to do this using data of this type? I have looked into the function comet() which does something similar but it does not take into account time of particle "entrance" so to speak. So if a particle appears a certain time after another, it does not take this into account (to my knowledge at least). Any ideas?
A simple example of the trajectories:
Particle 1
Trajectories(1).T = 0:0.1:1;
Trajectories(1).X = [45, 46, 48, 49, 50, 61, 63, 64, 63, 60, 61]
Trajectories(1).Y = [10, 12, 11, 13, 15, 16, 18, 20, 19, 22, 21]
Particle 2
Trajectories(2).T = 0.5:0.1:1;
Trajectories(2).X = [10, 14, 12, 14, 13, 11]
Trajectories(2).Y = [30, 32, 31, 33, 34, 36]
And so I would want to plot both of these particle positions on an X Y plane with timesteps of 0.1, taking "entrance" time into consideration (here particle1 enters at time 0 and particle2 enters from time 0.5)
Thanks
0 Commenti
Risposta accettata
Greg Dionne
il 26 Apr 2019
This should get you started:
load Trajectories.mat
hAxes = newplot;
colors = lines(10);
axis(hAxes,[0 1300 0 1100])
for i=1:10
hLine(i) = animatedline(hAxes,'Color',colors(i,:));
hText(i) = text(hAxes,NaN,NaN,num2str(i),'VerticalAlignment','bottom');
end
maxtime = max(horzcat(Trajectories(:).T));
for t = 0:.1:maxtime
for i=1:10
idx = find(Trajectories(i).T==t,1,'first');
if ~isempty(idx)
x = Trajectories(i).X(idx);
y = Trajectories(i).Y(idx);
addpoints(hLine(i),x,y);
hText(i).Position = [x y];
end
end
title(hAxes,sprintf('T = %6.1f',t));
drawnow
end
2 Commenti
Più risposte (1)
Image Analyst
il 29 Apr 2019
Attached is a demo where I did some stuff in an axes and made the result into a movie.
0 Commenti
Vedere anche
Categorie
Scopri di più su MATLAB Support Package for USB Webcams in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!