Scatter plotting in real time

조회 수: 4 (최근 30일)
Pranav Thiagarajan
Pranav Thiagarajan 2017년 3월 16일
댓글: Pranav Thiagarajan 2017년 3월 22일
Hello,
I am acquiring data from a sensor and am trying to scatter plot it in real time. My code goes like this:
f=figure
while datenum(clock)<endTime
message=judp('RECEIVE',40001,264);
.
. %parse message
.
Now I have an array 'a' with the data needed to plot.
for i=1:sizeof(a)
f=scatter3(a(i,1),a(i,2),a(i,3),'*')
hold on
end
The array 'a' keeps growing in size and my current code always creates a new figure window for each update of the plot. So, I end up with 20 graph windows rather than 1 continuously updating graph.
Is it possible to update the graph in real time as the data keeps coming in? I also don't want multiple figure windows opening up.
Thanks for any help.
Pranav

채택된 답변

KSSV
KSSV 2017년 3월 16일
편집: KSSV 2017년 3월 16일
x = rand(10,1) ; y = rand(10,1) ;
h = scatter(x,y,'Or') ;
for i = 1:100
x = rand(10,1) ;
y = rand(10,1) ;
set(h,'XData',x,'YData',y) ;
drawnow
pause(0.1)
end
  댓글 수: 1
Pranav Thiagarajan
Pranav Thiagarajan 2017년 3월 22일
Thank you! I also tried this for polar plots, but it doesnt seem to work. Do you know how I can do that?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by