Borrar filtros
Borrar filtros

How to setup Simulink logs out .mat format?

2 visualizaciones (últimos 30 días)
Szabó Bence Károly
Szabó Bence Károly el 24 de En. de 2022
Comentada: Szabó Bence Károly el 5 de Mayo de 2023
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

Respuesta aceptada

Sayani
Sayani el 21 de Nov. de 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 comentario
Szabó Bence Károly
Szabó Bence Károly el 5 de Mayo de 2023
Thanks for the answer. This is the solution i use now, but still feels like a workaround to me.

Iniciar sesión para comentar.

Más respuestas (1)

Muthukumar Ganesan
Muthukumar Ganesan el 20 de Ag. de 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;

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by