- 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 (최근 30일)
이전 댓글 표시
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
Walter Roberson
2020년 7월 8일
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:
참고 항목
카테고리
Help Center 및 File Exchange에서 Debugging and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!