Clear Filters
Clear Filters

How to buffer a certain amount of data in a buffer without saving all the data that passes through it?

13 views (last 30 days)
I have two approaches. The problem with the one in the zip file is that it is saving all the values everytime they pass to the matrix. I dont want to save them. I just want to process them and save just the ones that I am interested in.
The second approach has a problem when extracting the data out it. Its not extracting 1000 values is creating an array of arrays. The first point is repeated 1000 times, then second point 1000 and so on. Its a ring buffer.
Hope you can help me find a solution to it.
The idea is to process 20 sec = 1000 samples filter and process them and just save the data that I am interested in.

Answers (1)

Puru Kathuria
Puru Kathuria on 3 Jan 2021
You can try using a FIFO buffer (dsp.AsyncBuffer).
  1. Initialise the buffer of the appropriate size/capacity
  2. read data in a sequential manner and write to the buffer
  3. then read the buffer and do further processing
windowLength = 10;
dataBuff = dsp.AsyncBuffer(windowLength);
for iterator = 1:10
data = dataSource();
write(dataBuff, data);
%do further processing with this data
dataToFurtherProcess = read(dataBuff);
You can also try using dsp.SignalSource to create a real time streaming source.
Refer to this part of the example to see a similar buffer usage.




Community Treasure Hunt

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

Start Hunting!