Main Content

getLogAsSpecifiedInModel

Determine whether model logs as specified in model or uses override settings

    Description

    logMode = getLogAsSpecifiedInModel(mdlInfo,mdl) returns one of these values:

    • 1 (true) — The model specified by mdl is logged as specified in the model.

    • 0 (false) — The model specified by mdl is logged using the override settings specified in the Signals property of the model logging override object mdlInfo.

    example

    Examples

    collapse all

    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.

    Open the IterativeCounter project. The project opens the CounterSystem model at startup. This model contains a Model block that references the CounterAlgorithm model. In total, four signals are marked for logging. The top model has three signals marked for logging: BatchData, Controls, and OuterCount. The referenced model has one signal marked for logging: InnerCount.

    openProject("IterativeCounter");
    mdl = 'CounterSystem';
    mdlInner = 'CounterSystem/Model';

    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);
    out1 = sim(mdl);
    out1.logsout
    ans = 
    Simulink.SimulationData.Dataset 'logsout' with 3 elements
    
                             Name        BlockPath                 
                             __________  _________________________ 
        1  [1x1 Signal]      BatchData   CounterSystem/Concatenate
        2  [1x1 Signal]      OuterCount  CounterSystem/Model      
        3  [1x1 Signal]      Controls    CounterSystem/Subsystem  
    
      - 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 InnerCount signal.

    set_param(mdl,DataLoggingOverride=mdlInfo);
    out2 = sim(mdl);
    out2.logsout
    ans = 
    Simulink.SimulationData.Dataset 'logsout' with 1 element
    
                             Name        BlockPath                                
                             __________  ________________________________________ 
        1  [1x1 Signal]      InnerCount  ...l|CounterAlgorithm/For Each Subsystem
    
      - Use braces { } to access, modify, or add elements using index.
    
    

    Input Arguments

    collapse all

    Model logging override object, specified as a Simulink.SimulationData.ModelLoggingInfo object.

    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

    Version History

    Introduced in R2012b