Main Content

Simulink.SimulationData.ModelLoggingInfo.createFromModel

Create Simulink.SimulationData.ModelLoggingInfo object for top model with override settings for each logged signal in model

    Description

    mdlInfo = Simulink.SimulationData.ModelLoggingInfo.createFromModel(mdl) creates a model logging override object for the model mdl that includes logged signals for these kinds of systems:

    • Libraries

    • Masked subsystems

    • Referenced models

    • Active variants

    example

    mdlInfo = Simulink.SimulationData.ModelLoggingInfo.createFromModel(mdl,Name,Value) creates a Simulink.SimulationData.ModelLoggingInfo object for the model mdl with optional settings.

    example

    Examples

    collapse all

    You can create a model logging override object for the model sldemo_mdlref_bus and automatically add each logged signal in the model to that object. The model sldemo_mdlref_bus has four signals marked for logging.

    mdl = 'sldemo_mdlref_bus';
    open_system(mdl)
    mdlInfo = Simulink.SimulationData.ModelLoggingInfo.createFromModel(mdl)
    mdlInfo = 
      ModelLoggingInfo with properties:
    
                         Model: 'sldemo_mdlref_bus'
                   LoggingMode: 'OverrideSignals'
        LogAsSpecifiedByModels: {}
                       Signals: [1x4 Simulink.SimulationData.SignalLoggingInfo]
    
    

    The LoggingMode property is set to 'OverrideSignals', which configures the model logging override object to log only the signals specified in the Signals property.

    Apply the model override object settings. The software saves the settings when you save the model.

    set_param(mdl,'DataLoggingOverride',mdlInfo);

    You can use the options in the Simulink.SimulationData.ModelLoggingInfo.createFromModel function to specify how model components like variants and model references should be handled. For example, use the Variants name-value argument to create a model logging override object that includes logged signals in all variants of the model sldemo_variant_subsystems.

    By default, the sldemo_variant_subsystems model does not log any signals.

    mdl = 'sldemo_variant_subsystems';
    open_system(mdl)

    Start by configuring the output signals from the Linear Controller and Nonlinear Controller subsystems for logging.

    phLin = get_param("sldemo_variant_subsystems/Controller/Linear Controller",...
        "PortHandles");
    set_param(phLin.Outport(1),'DataLogging','on');
    phNonlin = get_param("sldemo_variant_subsystems/Controller/Nonlinear Controller",...
        "PortHandles");
    set_param(phNonlin.Outport(1),'DataLogging','on');
    

    Use the Simulink.SimulationData.ModelLoggingInfo.createFromModel function to create a model logging override object that includes the signals logged in all variant subsystems of the sldemo_variant_subsystems model.

    mdlInfo = Simulink.SimulationData.ModelLoggingInfo.createFromModel(...
    mdl, 'Variants', 'AllVariants')
    mdlInfo = 
      ModelLoggingInfo with properties:
    
                         Model: 'sldemo_variant_subsystems'
                   LoggingMode: 'OverrideSignals'
        LogAsSpecifiedByModels: {}
                       Signals: [1x2 Simulink.SimulationData.SignalLoggingInfo]
    
    

    Input Arguments

    collapse all

    Name of top model for which to create a Simulink.SimulationData.ModelLoggingInfo object, specified as a character vector.

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

    Example: mdlInfo = Simulink.SimulationData.ModelLoggingInfo.createFromModel(mdl, Variants = 'AllVariants')

    If you select more than one option, then the created Simulink.SimulationData.ModelLoggingInfo object includes signals that fit the combinations of the specified options. For example, if you set FollowLinks to on and RefModels to off, then the model signal logging override object does not include signals from library links that exist inside of referenced models.

    Option to follow links into library blocks, specified as 'on' or 'off'.

    • 'on' — Include logged signals from inside of libraries.

    • 'off' — Skip all libraries.

    Option to include logged signals from masked systems, specified as 'all', 'none', 'graphical', or 'functional'.

    • 'all' — Include logged signals from all masked subsystems.

    • 'none' — Skip all masked subsystems.

    • 'graphical' — Include logged signals from masked subsystems that do not have a workspace or dialog box.

    • 'functional' — Include logged signals from masked subsystems that do not have a dialog box.

    Option to include subsystem and model variants, specified as 'ActiveVariants' or 'AllVariants'.

    • 'ActiveVariants' — Include logged signals from only active subsystem and model variants.

    • 'AllVariants' — Include logged signals from all subsystem and model variants.

    Option to include logged signals from referenced models. specified as 'on' or 'off'.

    • 'on' — Include logged signals from referenced models.

    • 'off' — Skip all referenced models.

    Version History

    Introduced in R2012b