How can I disable signal logging across an entire Simulink model except a dedicated library?

13 views (last 30 days)
Hello Matlab Community,
I have been trying to disable all the signals in my simulink model except for a dedicated library which was created to centralize the signal logging in our project.
Currently there are more members in the project who abuse the model by doing signal logs everywhere instead of respecting the centralized library.
For this i have been searching for a solution and i came across this below link where we can disable the signals.
But the catch is the documentation is not perfect:
The get_param and set_param uses datalogging property only for scopes, toworkspace. Apart from these listed properties others are not available to modify or disable logging.
But as you know we can log wherever we want in simulink and next to whichever block we want.
When i try this by modifying the exception to skip library. it dosent work where it is logged else where except the scopes or to workspace.
Even in the documentaiton of dataLogging property it is not clearly mentioned that where this properties might take in to effect.
Do any of you have any idea of any other different property which can be used to disable the signal logging using a script or any other method?
The idea is to use this at the beginning of the save function to disable all the logging except leaving the centralized library logged as it is.

Answers (1)

Altaïr
Altaïr on 24 Mar 2025
The "Override Signal Logging Settings" option is useful for modifying the data logging properties of logged signals. More information can be found here:
The section "Override Signal Logging Settings from MATLAB" on the above page can provide guidance on creating a callback script, as illustrated below:
mi_extra = Simulink.SimulationData.ModelLoggingInfo.createFromModel(...
gcs, 'FollowLinks', 'off');
mi = Simulink.SimulationData.ModelLoggingInfo.createFromModel(...
gcs, 'FollowLinks', 'on');
for i = 1: length(mi_extra.Signals)
sigIdx = mi.findSignal(mi_extra.Signals(i).BlockPath,mi_extra.Signals(i).OutputPortIndex);
mi.Signals(sigIdx).LoggingInfo.DataLogging = 0;
end
set_param(gcs,'DataLoggingOverride',mi);
This script loads the signals being logged in the model. The variable mi contains all the logged signals, while mi_extra includes those not logged from within a library. The for loop is used to turn off the DataLogging property of the signals in mi_extra, and the modified logging information is then assigned to the model. This code can be placed in the PreSaveFcn callback of the top model. Here's an example model named "test" where the blocks "Scale by 5" and "Scale by 5_1" are from a custom library.
Note: To open the Simulink Signal Logging Selector, access the Configuration Parameters for the model and click on "Configure Signals to Log...".
Before saving the model, the Logging Mode is set to "Log all signals as specified in model", which means that overriding is turned off.
Upon saving the model, observe that the Logging Mode is set to "Override signals," and the DataLogging option is turned off for all signals not originating from the library.
For further details, the following documentation pages may be useful:

Categories

Find more on Prepare Model Inputs and Outputs in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!