Clear Filters
Clear Filters

How to access lag segment of data.dat and execute loop at a fixed frequency on it?

1 view (last 30 days)
Dear Matlab Community ,
1,I would like to perform my regular offline analysis online on my recorded data, while recording. My idea is to access a lagging part and perform some analysis and plotting via fixed frequency loop. Data is accessible from harddrive while recorded.
2, Is it possible to access such data via readmemory function? I guess it is buffered to somewhere before written on HDD. It would be faster.
PS: the task is far beyond my matlab coding abilities, however I would kindly try, please share related literature or tutorials etc.
Many thanks

Answers (1)

Jack on 31 Mar 2023
  1. It is possible to perform real-time analysis and plotting of recorded data while it is being recorded. One way to achieve this is to use a fixed frequency loop that reads a chunk of data from the hard drive at each iteration and performs the analysis and plotting on that chunk. The loop can then sleep for a fixed period of time before reading the next chunk of data. This approach requires careful tuning of the loop frequency and chunk size to ensure that the analysis and plotting can keep up with the data rate.
Another approach is to use a buffer to store a sliding window of data that is being recorded. The analysis and plotting can then operate on the buffer in real-time without needing to access the hard drive. This approach requires careful management of the buffer size and memory usage to avoid overflows or underflows.
  1. The readmemory function in MATLAB is designed to read data from the memory of another process or the operating system. It is not designed to read data that is being written to the hard drive. To read data from the hard drive in real-time, you can use functions such as fread or h5read to read chunks of data from the recorded file at each iteration of the loop.
There are several tutorials and examples available online that demonstrate real-time data analysis and plotting in MATLAB. Here are a few resources to get you started:
I hope this helps! Let me know if you have any further questions.


Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!