Storing Live streamed data
22 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
BionicP
el 30 de En. de 2021
Comentada: BionicP
el 6 de Feb. de 2021
Hi, so i am currently working on a project which is taking streamed data from a device to matlab. Now i am using this data to control a prosthesis but i am struggling to write some code that will store the data in an appropriate variable that can run classification (Machine learning) on the data. I have 4 channels worth of data, and the easiest part of this is i dont even need all the data saved, just the most significant feature i.e. only above a threshold.
The streamed data is coming in at a rate of 2000Hz but as i said before i only need the values after the thresholding. I simply am struggling with storing this data, the threhsold is of course easy. I dont know the size of the data to create as its live data which is a problem in itself (Not being able to run machine learning on the whole data).
I have been trying this for a while, if anyone can help it would be greatly appreciated.
0 comentarios
Respuesta aceptada
dpb
el 30 de En. de 2021
Editada: dpb
el 30 de En. de 2021
Open a file before beginning the process and write whatever it is that is wanted...formatted data is simple to read but bulky, stream data is compact and the fastest way...not having been given any of your code variables can't try to fit into whatever it is you do have, but the idea is
fid=fopen('LoggingFile.dat','w');
collecting=true;
while collecting
x=readdatafromsource;
y=threshold(x);
fwrite(fid,y,'double')
end
fid=fclose(fid);
The above presumes some other manner such as a pushbutton callback that sets the variable collecting to false to stop the collection process; you've apparently got all that worked out already.
Then just
fid=fopen('LoggingFile.dat','r');
data=fread(fid);
fid=fclose(fid);
will give you the saved data in a 2D array, assuming the x data are a 4-vector as described for each collection cycle.
ADDENDUM:
Alternatively, if you have sufficent memory, hold the data in memory and use a .mat file at the end.
8 comentarios
dpb
el 6 de Feb. de 2021
This is tougher for us to help with; we don't have the means to run the code so you've got to do the heavy lifting. We can give advice or answer syntax errors or even help diagnose further symptoms, but that's about all...
Más respuestas (0)
Ver también
Categorías
Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!