How can I disable data logging for all the signals in my model?
조회 수: 178 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2018년 7월 11일
편집: Simon Silge
2024년 7월 9일 10:15
I have enabled data logging for a lot of signals in my model, how can do this via command line functions?
채택된 답변
MathWorks Support Team
2018년 7월 11일
The following code will disable signal logging for all the signals in the model ('gcs' can be replaced by the model name):
mdlsignals = find_system(gcs,'FindAll','on','LookUnderMasks','all','FollowLinks','on','type','line','SegmentType','trunk');
ph = get_param(mdlsignals,'SrcPortHandle')
for i=1: length(ph)
set_param(ph{i},'datalogging','off')
end
댓글 수: 2
Asvin Kumar
2020년 9월 7일
For those who want to copy paste this into a laaarge model...
...add a semicolon on line 2.
My ph variable had an output of length 2077x1. :/
Simon Silge
2024년 7월 9일 10:01
편집: Simon Silge
2024년 7월 9일 10:15
Just to add another pointer: you can override your logging settings using the Signal Logging Selector and deactivate all logging for a model there. The advantage is that you can afterwards switch back to your original setup with all signals logging as specified before.
To open go to: Simulink Toolstrip: On the Modeling tab, click Model Settings > Data Import/Export. Then, click Configure Signals to Log.
On the top you can choose between different logging modes. Choose "Override signals". Next select all the signals on the list on the right (Ctrl+A to select all).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1730886/image.png)
For model references you can also specify here how they should behave. When you want to go back to your original setting you can change from "override signals" to "Log all signals as specified in model".
If you have subsystems and model references the workflow via UI is still cumbersome as you need to go through them one by one. But you can also use this tool programmatically:
추가 답변 (1개)
Keqin Xu
2020년 11월 3일
I made a convenient shortcut out of the following script.
% this will remove logging of any selected signals in the SimuLinkmodel
mn=inputdlg({'Input SimuLink Model Name:'},'',1,{''});
if ~isempty(mn)
if exist(mn{1})==4
mdlsignals = find_system(mn,'FindAll','on','LookUnderMasks','all','FollowLinks','on','type','line','SegmentType','trunk');
ph = get_param(mdlsignals,'SrcPortHandle');
for i=1: length(ph)
set_param(ph{i},'datalogging','off')
end
msgbox(['Any signal loggings in "',mn{1},'" have been removed.'])
else
msgbox(['"',mn{1},'" is not a valid SimuLink model.'])
end
end
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!