plotting data on a refresh rate
이전 댓글 표시
I am working on a project where I am plotting received data from a port continously, at the moment I am able to do that but the data each time is plotted on a separate figure I want the data to be plotted on one figure on which this figure is refreshed at everytime the data is plotted.
답변 (1개)
Adam Danz
2019년 12월 23일
0 개 추천
Somewhere in your code a figure is being generated explicitly, perhaps with the figure() command. That needs to be removed. To add data to an existing plot, it's best to include the axis handle in the plotting function inputs. You'll also need to issue the hold on command.
That's about as specific as I can get without seeing the plotting code.
댓글 수: 4
ahmed abdelmgeed
2019년 12월 23일
편집: Adam Danz
2019년 12월 23일
Yep, my intuition was correct. Your 3rd line of code is telling matlab to produce a figure on each iteration.
Instead, prior to your loop you can produce the figure.
% Produce the figure prior to the loop
finalFigure = figure(. . .);
finalFigureAxes = axes(finalFigure);
hold(finalFigureAxes, 'on');
% Update the axes
for i = 1:x
. . .
plot(finalFigureAxes, . . .)
. . .
end
ahmed abdelmgeed
2019년 12월 25일
Adam Danz
2019년 12월 26일
In order to diagnose the problem I'd need to run the code.
Since I don't have all of the information necessary to run the code, my first guess would be that the y-axis limit isn't being set correctly.
Comment-out (or remove) the two lines in your code that are setting the ylim() to test that.
Have you looked at the values of bufferChA, bufferChB, time?
카테고리
도움말 센터 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!