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

22 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

the cyclist
the cyclist el 21 de Oct. de 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 comentario
Heraldo Tello
Heraldo Tello el 22 de Oct. de 2020
yes this exactly what I wanted it plotted each point with a delay of 1 second without storing the previous point

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by