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

22 次查看(过去 30 天)
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.

采纳的回答

the cyclist
the cyclist 2020-10-21
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

产品


版本

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by