- Read from all devices, but use the sensor number loop to write out only the data relevant to that sensor number. For example if sensor #3 was selected you might write out g and otherwise not write out g; OR
- Loop over the active sensors, reading the q, a, g, m from the specific sensor, writing it out, and not reading from any sensor that is not selected.
Cell array saving in real-time
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi all,
I'm pretty new in Matlab. I'm trying to save in real-time data received from sensors. An event manages the sensor data transmission, which is represented by the update of a data package: each time the event is called, a new data package is available. The number of samples constituting the package is variable in time.
In the following script, I simulate three packages of different number of samples (scanNumber), and two selected sensors from the users (sensorNum). Each sensor gives four different measures (blockSensor).
scanNumber = [10 11 9]; %number of samples for each package
blockSensor = 4; %each sensor produces 4 different measures
sensorNum = 2; %number of sensor selected by the user
measure1 = cell(sensorNum, 1);
measure2 = cell(sensorNum, 1);
measure3 = cell(sensorNum, 1);
measure4 = cell(sensorNum, 1);
saveCell = cell(1, blockSensor * sensorNum);
for package = 1:1:length(scanNumber)
% the following four lines simulate sensor readings
q = 1*ones(scanNumber(package), 4);
a = 2*ones(scanNumber(package), 3);
g = 3*ones(scanNumber(package), 3);
m = 4*ones(scanNumber(package), 3);
for sensor = 1:1:sensorNum
% data association from sensor readings to measurements arrays
measure1{sensor} = q;
measure2{sensor} = a;
measure3{sensor} = g;
measure4{sensor} = m;
% saving array
saveCell{-3+(sensor*blockSensor)} = measure1{sensor};
saveCell{-2+(sensor*blockSensor)} = measure2{sensor};
saveCell{-1+(sensor*blockSensor)} = measure3{sensor};
saveCell{ (sensor*blockSensor)} = measure4{sensor};
end
% SAVE THE PACKAGE HERE
end
I would like to save the cell array (saveCell) in a file in an efficient way minimizing at maximum the time consumption for the writing operation and minimizing the space occupied on the disk from the file. I need to append the new values in saveCell to its old values already saved in the file, every time a new package is available.
Thank you all,
Johnny
2 Commenti
Walter Roberson
il 8 Lug 2020
The logic you post simulates fetching all of the data, and then loops through the number of sensors writing the same infromation to each one. Are you sure that is representative of your work flow?
It would make more sense if you had one of the following possibilities:
Vedere anche
Categorie
Scopri di più su Debugging and Analysis in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!