- Setup a connection to serial port and read the data. For this purpose you can use the "serialport" function to establish a communication channel with the serial port. You can find the documentation for the function here: https://www.mathworks.com/help/matlab/ref/serialport.html
- For creating a real time plot, retrieve the data chunks from the serial port and keep adding them to the same figure by using the "hold on" command or the "drawnow" function. You can also have a look at the following MATLAB Answer describing a few ways to plot in real time: https://www.mathworks.com/matlabcentral/answers/83192-plot-in-real-time
- In the end, you need to close the serialport objects. Leverage the following post for understanding the steps needed for closing the serial port: https://www.mathworks.com/matlabcentral/answers/886269-how-do-i-close-serialport-objects
How to plot data sensor on GUI Matlab
조회 수: 3 (최근 30일)
이전 댓글 표시
채택된 답변
Shubham
2024년 9월 8일
편집: Shubham
2024년 9월 8일
Hey John,
I believe you need assistance in plotting real time data from an STM32F411 sensor.
In order to achieve this, you would need to:
As an alternative to the above proposed steps, make use of the following File Exchange Submission which has a MATLAB script designed for plotting graphs by accessing serial port data in real time: https://www.mathworks.com/matlabcentral/fileexchange/28941-real-time-data-plot-from-serial-port
I hope this helps!
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!