setLogAsSpecifiedInModel
Set logging mode for top model or top-level Model block
Description
Examples
Set Logging Mode of Model Logging Override Object
You can use the setLogAsSpecifiedInModel
function to override signal logging settings specified in a model. For example, you can log only the top model or only a referenced model in a model hierarchy. The model sldemo_mdlref_bus
contains a Model block named CounterA
that references the model sldemo_mdlref_counter_bus
. In total, four signals are marked for logging. The top model has three signals marked for logging: COUNTERBUS
, INCREMENTBUS
, and OUTERDATA
. The referenced model has one signal marked for logging: INNERDATA
.
mdl = 'sldemo_mdlref_bus'; mdlInner = 'sldemo_mdlref_bus/CounterA'; open_system(mdl)
Create an empty Simulink.SimulationData.ModelLoggingInfo
object so that no signals are logged when the logging mode is set to the override settings specified in the Signals
property.
mdlInfo = Simulink.SimulationData.ModelLoggingInfo(mdl);
You can use the setLogAsSpecifiedInModel
function to log only signals in the top model using the logging settings specified in that model. Set the outer model to log signals as specified in the model. Then, set the inner model to use override settings. Since the Signals
property vector is empty, no signals are logged when override settings are applied.
mdlInfo = setLogAsSpecifiedInModel(mdlInfo,mdl,true); mdlInfo = setLogAsSpecifiedInModel(mdlInfo,mdlInner,false);
The getLogAsSpecifiedInModel
function returns the logging mode.
outerLogMode = getLogAsSpecifiedInModel(mdlInfo,mdl)
outerLogMode = logical
1
innerLogMode = getLogAsSpecifiedInModel(mdlInfo,mdlInner)
innerLogMode = logical
0
Apply the model override object settings. Then, simulate the model. The software logs only those signals marked for logging in the top model.
set_param(mdl,'DataLoggingOverride',mdlInfo);
sim(mdl);
topOut
topOut = Simulink.SimulationData.Dataset 'topOut' with 3 elements Name BlockPath ____________ _____________________________________ 1 [1x1 Signal] COUNTERBUS sldemo_mdlref_bus/Concatenate 2 [1x1 Signal] OUTERDATA sldemo_mdlref_bus/CounterA 3 [1x1 Signal] INCREMENTBUS sldemo_mdlref_bus/IncrementBusCreator - Use braces { } to access, modify, or add elements using index.
You can also use the setLogAsSpecifiedInModel
function to log only signals in the referenced model using the logging settings specified in that model. Set the outer model to use override settings. Then, set the inner model to log signals as specified in the model.
mdlInfo = setLogAsSpecifiedInModel(mdlInfo,mdl,false); mdlInfo = setLogAsSpecifiedInModel(mdlInfo,mdlInner,true);
To verify that the logging mode for the top model and inner model have changed, you can use the getLogAsSpecifiedInModel
function.
outerLogMode = getLogAsSpecifiedInModel(mdlInfo,mdl)
outerLogMode = logical
0
innerLogMode = getLogAsSpecifiedInModel(mdlInfo,mdlInner)
innerLogMode = logical
1
Apply the model override object settings. Then, simulate the model. This time, the software logs only the INNERDATA
signal.
set_param(mdl,'DataLoggingOverride',mdlInfo);
sim(mdl);
topOut
topOut = Simulink.SimulationData.Dataset 'topOut' with 1 element Name BlockPath _________ ________________________________________ 1 [1x1 Signal] INNERDATA ...erA|sldemo_mdlref_counter_bus/COUNTER - Use braces { } to access, modify, or add elements using index.
Input Arguments
mdlInfo
— Model logging override object
Simulink.SimulationData.ModelLoggingInfo
object
Model logging override object, specified as a
Simulink.SimulationData.ModelLoggingInfo
object.
mdl
— Target model
character vector
Target model, specified as a character vector. You can define the target model using one of these options:
Name of the top model
Block path of a Model block in the top model
logMode
— Logging mode
true
or 1
(default) |
false
or 0
Logging mode, specified as a numeric or logical 1
(true
) or 0
(false
).
true
— The model specified bymdl
is logged as specified in the model.false
— The model specified bymdl
is logged using the override settings specified in theSignals
property of theSimulink.SimulationData.ModelLogginIfo
object.
Version History
Introduced in R2012b
See Also
Objects
Functions
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)