Azzera filtri
Azzera filtri

How to setup Simulink logs out .mat format?

7 visualizzazioni (ultimi 30 giorni)
Hello,
I log a lot of signal in Simulink, with The following setup:
in(i) = in(i).setModelParameter(...
'LoggingToFile', 'On',...
'LoggingFileName', newFileName,...
'SaveFormat', 'Dataset',...
'SaveTime', 'off',...
'SaveState', 'off',...
'SaveOutput', 'off',...
'SaveFinalState', 'off',...
'DSMLogging', 'off',...
'ReturnWorkspaceOutputs', 'on',...
'Profile', 'off',...
'InspectSignalLogs', 'off',...
'DatasetSignalFormat', 'timeseries'...
);
The version 7.3 .mat size is almost 2-3 times larger than the version 7.0. That is why I would like to create a version 7 .mat, but it seems Simulink will create a 7.3 mat file anyway. (In the preferences > General > Mat-File - 7.0 option is selected but not really matters which one I select.)
If I load the .mat to the matlab workspace and call
data = load('FileFromSimulink.mat');
save('FileFromSimulink.mat', '-v7', '-struct', 'data')
It will create the expected .mat with reduced size. How can I avoid this extra step to load the files then save it.
Thanks,
B

Risposta accettata

Sayani
Sayani il 21 Nov 2022
You can avoid this extra step by adding "Callbacks" to your model. "Callbacks" can be accessed through "Model Properties".
In this particular case, you should add your script to change MAT File version in "StopFcn" under "Callbacks" section. This would then generate a v7.0 MAT File for you automatically everytime the model is executed.
  1 Commento
Szabó Bence Károly
Szabó Bence Károly il 5 Mag 2023
Thanks for the answer. This is the solution i use now, but still feels like a workaround to me.

Accedi per commentare.

Più risposte (1)

Muthukumar Ganesan
Muthukumar Ganesan il 20 Ago 2022
Hi,
In the newer versions of matlab by default, Simulink creates .mat file with version 7.3
You can add these commands in Model Properties -> Callbacks -> StopFcn
Thanks.
data = load('FileFromSimulink.mat');
save('FileFromSimulink.mat', '-v7', '-struct', 'data');
clear data;

Categorie

Scopri di più su Simulink Functions in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by