how to plot only one datapoint at a time with a 1 second delay from a dataset

21 vues (au cours des 30 derniers jours)
Hello everyone,
I have a matrix made of 3 columns and a random number of rows (for example TestPoints=[1 4 6;2 1 4;3 2 3;4 1 5;5 3 4;6 1 6;7 2 6;8 2 6];). I want to plot the second and third column (will call these X & Y). I do not care about the first column. The first column could be thought as time in seconds and the second and third coumns are Measurement 1 and Measurement 2 respectively.
However, I want to plot the first X and Y point first, followed by a 1 second delay before it plots the next X and Y point. I want it to keep doing this until it has gone through every row. Note: I do not want the previous point to show on the plot when the new point is plotted.

Réponse acceptée

the cyclist
the cyclist le 21 Oct 2020
Here is one way:
TestPoints=[1 4 6;2 1 4;3 2 3;4 1 5;5 3 4;6 1 6;7 2 6;8 2 6];
figure
for nr = 1:size(TestPoints,1)
plot(TestPoints(nr,2),TestPoints(nr,3),'.','MarkerSize',40);
set(gca,'XLim',[min(TestPoints(:,2)),max(TestPoints(:,2))],'YLim',[min(TestPoints(:,3)),max(TestPoints(:,3))])
pause(1)
end
  1 commentaire
Heraldo Tello
Heraldo Tello le 22 Oct 2020
yes this exactly what I wanted it plotted each point with a delay of 1 second without storing the previous point

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

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

Produits


Version

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by