How to plot real time data from text file

5 Ansichten (letzte 30 Tage)
Thomas
Thomas am 6 Jan. 2014
Kommentiert: Emma Donnelly am 18 Nov. 2019
Im new to matlab coding so im still trying to get my head around things. Pretty much im working with interia sensors which output the sensors orientation data every 10ms. Im able to store this data into a text file which is continuously updating.
My task now is to plot this data in real time. This involves continuously accessing and reading from the text file (every 10ms if possible) and graph this data with respect to time. Can any of you guys give me some guidance onto what would be the most effective way to do this.
The text file stores 2 sets of data (stored in separate columns in the text file) and both need to be graphed on the same plot with respect to time.
I can store this data into the text file in 2 way: Method 1: New data every 10ms. Each is stored in a new line. Method 2: I can make the text file only have the most recent piece of data (erasing previous data) Im able to use either of these methods.. whatever you guys think would be easier.
Ive tried using other 3rd party software to graph this data from the text file, but they all seemed really jumpy and couldnt read from the text file fast enough.
Thanks.
  1 Kommentar
Emma Donnelly
Emma Donnelly am 18 Nov. 2019
Hi Thomas,
I am facing a similar challenge. I was wondering if you might be willing to share the code you're working with?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

per isakson
per isakson am 8 Jan. 2014
Bearbeitet: per isakson am 8 Jan. 2014
I've spend some time with a Matlab program (Windows 7), which communicates with another program by reading and writing text files.
Some comments:
  • 10ms with plain Matlab is a challenge.
  • Does the text file contain a time stamp?
  • "Method 2" is faster and easier.
  • How to synchronize the two processes? Risk of missing data points.
  • Low level handle graphic is faster: set(axes_handle,'Ydata',y_value); etc.
  • Use the Matlab's timer
  • There are special toolboxes, e.g Instrument Control Toolbox and Data Acquisition Toolbox. I don't know whether they would help.
  • Unix or Windows might make a difference.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by