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

24 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by