필터 지우기
필터 지우기

Plot in real time inside a loop

조회 수: 20 (최근 30일)
Paul Pogba
Paul Pogba 2019년 4월 16일
댓글: Walter Roberson 2019년 10월 15일
I'm reading data from ADC in real time (while loop) and I'm trying to plot in real time. Now, I can't use
pause on; hold on; etc
Because it interferes with ADS's API and how it samples the data. My code looks something like that and it does plot in real time.
while 1 %sampling from ADC
%figure(1); if I uncomment just this line, API crashes
plot(x, datafromADC)
drawnow;
end
But if I want to plot to two different figures at the same time, I can't do it, ADC stops sampling and gives me criptic errors. I try to do something like that:
while 1 %sampling from ADC
figure(1);
plot(datafromADC);
drawnow;
if cond == 1
figure(2);
plot(datafromADC*2);
dranow;
end
end
Is there another way to plot to two different figures inside the loop? Should I use something else instead of 'dranow'?
I'm using DATAQ DI-1110 and its MATLAB API.

채택된 답변

Walter Roberson
Walter Roberson 2019년 4월 16일
편집: Walter Roberson 2019년 4월 16일
fig1 = figure(1);
ax1 = axes('Parent', fig1);
ph1 = plot(ax1, nan, nan);
fig2 = figure(2);
ax2 = axes('Parent', fig2);
ph2 = plot(ax2, nan, nan);
while true
update data at this point
set(ph1, 'XData', x, 'YData', datafromADC);
set(ph2, 'XData', x, 'YData', datafromADC*2);
drawnow limit;
end
  댓글 수: 2
Paul Pogba
Paul Pogba 2019년 4월 16일
If I use plot3 instead of plot, how should the code outside of while loop look like?
ph1 = plot3(ax1, nan, nan);
Walter Roberson
Walter Roberson 2019년 10월 15일
ph1 = plot3(ax1, nan, nan, nan);
and you would likely need to update the ZData property as well.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by