フィルターのクリア

How to setup Simulink logs out .mat format?

7 ビュー (過去 30 日間)
Szabó Bence Károly
Szabó Bence Károly 2022 年 1 月 24 日
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

採用された回答

Sayani
Sayani 2022 年 11 月 21 日
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 件のコメント
Szabó Bence Károly
Szabó Bence Károly 2023 年 5 月 5 日
Thanks for the answer. This is the solution i use now, but still feels like a workaround to me.

サインインしてコメントする。

その他の回答 (1 件)

Muthukumar Ganesan
Muthukumar Ganesan 2022 年 8 月 20 日
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;

カテゴリ

Help Center および File ExchangeSimulink Functions についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by