How to develop a FIFO Circular Buffer for analyzing real-time data?

조회 수: 64(최근 30일)
I'm working on a project using the Polhemus Liberty system for real-time motion tracking. Recently, I have developed a GUI in Matlab's GUIDE to acquire the position and orientation of the attached sensors at a 240Hz sampling frequency. Also, I added an artificial neural network (ANN) to do some predictions on the kinematic parameters in real-time. However, after having the ANN's predictions I should do some data analysis on multiple dimension arrays. Without having the real-time criteria this particular data analysis could only be done by adding multiple nested loops because of the high dimensionality. The issue is that if I add FOR loops to the method then the real-time (or close to real-time) criteria will definitely be harmed. In order to avoid the addition of the nested FOR loops I thought I could create a buffer (FIFO circular buffer) to temporarily store the predicted data and have the data analyzed. I have found a smart solution under the following link:
In my understanding, the above solution works as a '1 frame/sec' method. So after capturing an image and defining its 'centroid data' only one column will be either removed or expanded in the buffer mechanism. This works quite well in that particular case. What would happen if the sampling rate is not 1 sample/sec but 240Hz. Given an infinite while loop the data loss will be increased without changing the parameters of the buffer.
Does somebody have an idea how to either modify the linked solution or to create a completely new one? In the buffer I should have 100 samples to analyze.
Let's have some brainstorming on it! I'm opened to have some smart ideas. Thanks in advance, Rob

채택된 답변

Anver Hisham
Anver Hisham 2016년 9월 13일
편집: Walter Roberson 2016년 9월 13일
In case you are looking for a circular buffer implementation, here is the one I'm using,
This is an extension of double class, so you can input it to any function accepting vectors/matrices.

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by