필터 지우기
필터 지우기

Dynamic data plotting

조회 수: 5 (최근 30일)
skyimager
skyimager 2012년 5월 30일
How to do dynamic plotting of data. I am receiving data continuously from the serial port (data given by a sensor). Now i want to plot the data in my gui simultaneoulsy in real time. As and when data is coming the plot should get updated. I have spent hours on this but no output.
  댓글 수: 1
Oleg Komarov
Oleg Komarov 2012년 5월 30일
Check the timer() and set() functions.
If you want more details you have to provide more: http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer

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

답변 (1개)

Walter Roberson
Walter Roberson 2012년 5월 30일
Set up the serial port with BytesAvailableFcnCnt = 1, BytesAvailableMode = 'byte', and BytesAvailableFcn being a function that adds the character to the current plot.
This arrangement is likely to end up dropping characters, as the overhead of calling the plot function once per byte is likely going to be too high. You should reconsider your "real time" and "when data is coming" requirements, keeping in mind that your display probably cannot update more than 60 times per second (and possibly only 12 times per second if you are using an LCD display from one of the first several generations.)
  댓글 수: 2
skyimager
skyimager 2012년 5월 30일
sir..thank you for ur answer. I want to update the data once every 2 secs. The problem is once the gui starts..the text box takes in only the first value. I have to click a refresh button in my gui to get the subsequent values. If only the values can be stored in an array which can then be plotted.
Walter Roberson
Walter Roberson 2012년 5월 30일
data_array = [data_array, newly_read_data];
Save that somewhere your plot routine can get at it, and trigger the plot routine. The plot routine should have a drawnow() to update the graphics.

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

카테고리

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