Plotting of a rolling ball
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi all,
I have data as below. First column is time column. The second column is x values and the third column is y values. I want to plot this data.The data shows that a round ball is at the x and y location at given time. This ball seems to be shifting/rolling. How can I plot this movement of the ball? The data is as follows.
Thanks.
0 0 0
0.00500000000000000 -1.99184823748972e-07 1.05798917365090e-13
0.0100000000000000 -9.95522559684969e-07 2.64284044491124e-12
0.0150000000000000 -2.70844960991857e-06 1.95618647719148e-11
0.0200000000000000 -5.57897138597691e-06 8.29997912681309e-11
0.0250000000000000 -9.72602113360498e-06 2.52254632243548e-10
0.0300000000000000 -1.52681885391364e-05 6.21646883377640e-10
0.0350000000000000 -2.24451354098218e-05 1.34342427617396e-09
0.0400000000000000 -3.12528324201816e-05 2.60463875809055e-09
0.0450000000000000 -4.14440486717297e-05 4.58029112081254e-09
0.0500000000000000 -5.27718390114465e-05 7.42631198040007e-09
0.0550000000000000 -6.49895772581970e-05 1.12630537391977e-08
0.0600000000000000 -7.79724695483816e-05 1.62125493532621e-08
0.0650000000000000 -9.15958589238721e-05 2.23728036586717e-08
0.0700000000000000 -0.000105613752470057 2.97447058954838e-08
0.0750000000000000 -0.000119902041788388 3.83373323333985e-08
0 commentaires
Réponse acceptée
VBBV
le 24 Mai 2024
Modifié(e) : VBBV
le 24 Mai 2024
@Cem Eren Aslan, you can use plot function handle and delete it at end of every iteration inside the loop,
data = [0 0 0
0.00500000000000000 -1.99184823748972e-07 1.05798917365090e-13
0.0100000000000000 -9.95522559684969e-07 2.64284044491124e-12
0.0150000000000000 -2.70844960991857e-06 1.95618647719148e-11
0.0200000000000000 -5.57897138597691e-06 8.29997912681309e-11
0.0250000000000000 -9.72602113360498e-06 2.52254632243548e-10
0.0300000000000000 -1.52681885391364e-05 6.21646883377640e-10
0.0350000000000000 -2.24451354098218e-05 1.34342427617396e-09
0.0400000000000000 -3.12528324201816e-05 2.60463875809055e-09
0.0450000000000000 -4.14440486717297e-05 4.58029112081254e-09
0.0500000000000000 -5.27718390114465e-05 7.42631198040007e-09
0.0550000000000000 -6.49895772581970e-05 1.12630537391977e-08
0.0600000000000000 -7.79724695483816e-05 1.62125493532621e-08
0.0650000000000000 -9.15958589238721e-05 2.23728036586717e-08
0.0700000000000000 -0.000105613752470057 2.97447058954838e-08
0.0750000000000000 -0.000119902041788388 3.83373323333985e-08];
t = data(:,1);
x = data(:,2);
y = data(:,3);
for k = 1:numel(x)
h=plot(x(k), y(k), 'bo', 'MarkerFaceColor', 'b');
pause(2);
delete(h); % deletes the previous location /position of ball in figure
end
0 commentaires
Plus de réponses (1)
Animesh
le 24 Mai 2024
You can use the plot function in MATLAB for simple visualization of the given 2D trajectory.
You can refer the following MATLAB Documention for more information on plot function: www.mathworks.com/help/matlab/ref/plot.html
Moreover, to visualize the movement over time you can use the loop to draw the position of ball at each time step. You can do something like this to visualize the movement:
for i = 1:length(x)
plot(x(i), y(i), 'ro', 'MarkerFaceColor', 'r');
pause(0.1); % Adjust the speed of animation by changing the pause duration
end
Voir également
Catégories
En savoir plus sur Multirate Signal Processing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!