Please check Timetable log data as attached.
How to write Array signals log data into MF4 file format?
19 views (last 30 days)
Show older comments
Hello,
I have some log data from Simulink model. Now I wanted to write all the output log data into MF4 file format. For this, I have converted the model test data into 'Timetable' format and to write these logs into MF4 using command "mdfWrite('abc.mf4',c)", where abc.mf4 is file name and c is Timetable data.
Easily able to write the logs into mf4 if the signals are of single dimension.
Now my issue comes, when the log data contains array signals with different dimensions (I.e., 2, 3, ….,dimensions). Please check snap below of 6 dimension data and error as highlighted.
Is there any other way to convert the logs data into MF4 file using MATLAB?
Accepted Answer
Lokesh
on 26 Apr 2024
Edited: Lokesh
on 26 Apr 2024
Hi Manish,
It is my understanding that you are encountering an error while trying to write data that contains array signals with different dimensions. This issue arises because the "mdfWrite" function does not support writing array channels or structure channels.
As a workaround, you can consider flattening or reshaping these multidimensional arrays into a series of one-dimensional arrays that can be stored in the timetable as separate variables. This process requires you to manually handle the multidimensional data to convert it into a compatible format.
Here is a sample code snippet for reshaping multidimensional array:
signal2D = rand(6, 3); % Random data representing 3 sensors over 6 time points
signalCellArray = num2cell(signal2D, 2);
timeVector = seconds(0:5);
% Multidimensional Array
tt = timetable(timeVector', signalCellArray, 'VariableNames', {'MultiDimSensorData'});
% Extracting the multidimensional sensor data
numTimePoints = size(tt.MultiDimSensorData, 1);
sensor1Data = zeros(numTimePoints, 1);
sensor2Data = zeros(numTimePoints, 1);
sensor3Data = zeros(numTimePoints, 1);
% Loop through each time point to extract data for each sensor
for i = 1:numTimePoints
sensorData = tt.MultiDimSensorData{i}; % Extract the cell containing the current time point's data
sensor1Data(i) = sensorData(1);
sensor2Data(i) = sensorData(2);
sensor3Data(i) = sensorData(3);
end
% Create a new timetable with the extracted data
newTT = timetable(tt.Time, sensor1Data, sensor2Data, sensor3Data,'VariableNames', {'Sensor1', 'Sensor2', 'Sensor3'});
Refer to the following documentation for more information on "mdfWrite" function:
Hope this helps!
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!