How to create animated scatter plot with 2 data sets?

2 ビュー (過去 30 日間)
Andrew Rowley
Andrew Rowley 2019 年 6 月 26 日
コメント済み: Andrew Rowley 2019 年 6 月 26 日
Hello, I am a beginner with MATLAB but I am trying to create a scatter plot that plots data points one by one from 2 different data sets simultaneously, creating an animated scatter plot. I have code to create the scatter plot but only with one data set, I am unsure how to add in the second set of data. For example, the data I am plotting are the x and y coordinates of a drill held in one hand during surgery and a suction irrigator held in the other hand - I want to follow the scatter dots as if they are the hands.
Here is what I currently have.
Drill = readtable('matlab_test');
X = Drill{:,1};
Y = Drill{:,2};
plot1 = scatter(X(1),Y(1),60,'.');
axis([-2.5 2.5 -1.5 1.5])
for k=2:length(X)
plot1.XData=X(k);
plot1.YData=Y(k);
pause(0.03);
end
I have been stuck on how I can add the other data and have it plotting at the same time as the this data.
Hope this makes sense, thanks.
  2 件のコメント
KSSV
KSSV 2019 年 6 月 26 日
Use a loop and hold on.
Andrew Rowley
Andrew Rowley 2019 年 6 月 26 日
Using hold on has only been letting me graph one set of data at a time, not simultaneously. Perhaps I am putting the hold on in the wrong line?

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by