필터 지우기
필터 지우기

How to setup Simulink logs out .mat format?

조회 수: 7 (최근 30일)
Szabó Bence Károly
Szabó Bence Károly 2022년 1월 24일
댓글: Szabó Bence Károly 2023년 5월 5일
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 CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by