How to plot real time data from text file

5 visualizaciones (últimos 30 días)
Thomas
Thomas el 6 de En. de 2014
Comentada: Emma Donnelly el 18 de Nov. de 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 comentario
Emma Donnelly
Emma Donnelly el 18 de Nov. de 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?

Iniciar sesión para comentar.

Respuesta aceptada

per isakson
per isakson el 8 de En. de 2014
Editada: per isakson el 8 de En. de 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.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by