Main Content

verifySignalAndModelPaths

Verify paths in Simulink.SimulationData.ModelLoggingInfo object

    Description

    verifiedObj = verifySignalAndModelPaths(mdlInfo) returns a verified model logging override object, verifiedObj, if the function detects no invalid paths for the model logging override object mdlInfo. If an invalid path is found, verifySignalAndModelPaths returns an error.

    For a Simulink.SimulationData.ModelLoggingInfo object, the verifySignalAndModelPaths function verifies that:

    • All character vectors in the LogAsSpecifiedByModels property are either the name of the top model or the block path of a Model block in the top model.

    • The block paths for signals in the Signals property refer to valid blocks within the hierarchy of the top model.

    • The OutputPortIndex property for all signals in the Signals property are valid for the given block.

    • All signals in the Signals property refer to logged signals.

    If you use the Simulink.SimulationData.ModelLoggingInfo constructor and specify a Simulink.SimulationData.SignalLoggingInfo object for each signal, you can use the verifySignalAndModelPaths function to verify that your object definitions are valid.

    verifiedObj = verifySignalAndModelPaths(mdlInfo,action) specifies what action the verifySignalAndModelPaths function performs if an invalid path is found.

    example

    Examples

    collapse all

    You can use Simulink.SignalData.SignalLoggingInfo objects to programmatically override logging settings for specific signals. For example, you can create a Simulink.SimulationData.SignalLoggingInfo object to override the signal logging settings such that only one of several signals marked for logging is logged.

    This example uses a model of a rotating clutch system. In the model, ten signals are marked for logging. For more information about the model, see Building a Clutch Lock-Up Model.

    mdl = "sldemo_clutch_override";
    open_system(mdl);

    You can use a Simulink.SimulationData.SignalLoggingInfo object to log only the VehicleSpeed signal. The VehicleSpeed signal is connected the second output port of the Unlocked subsystem. Create a Simulink.SimulationData.SignalLoggingInfo object for the VehicleSpeed signal by using the BlockPath and OutputPortIndex properties.

    blkPath = "sldemo_clutch_override/Unlocked";
    portNum = 2;
    sigInfo = Simulink.SimulationData.SignalLoggingInfo(blkPath,portNum);

    Create an empty Simulink.SimulationData.ModelLoggingInfo object. Then, assign the signal logging override settings sigInfo to the model logging information object.

    mdlInfo = Simulink.SimulationData.ModelLoggingInfo(mdl);
    mdlInfo.Signals(1) = sigInfo;

    Use the verifySignalAndModelPaths function to ensure that you specified valid signal logging settings for the model.

    verifiedObj = verifySignalAndModelPaths(mdlInfo)
    verifiedObj = 
      ModelLoggingInfo with properties:
    
                         Model: 'sldemo_clutch_override'
                   LoggingMode: 'OverrideSignals'
        LogAsSpecifiedByModels: {}
                       Signals: [1x1 Simulink.SimulationData.SignalLoggingInfo]
    
    

    Apply the model override object settings using the set_param function.

    set_param(mdl,'DataLoggingOverride',mdlInfo)

    Simulate the model. Verify that VehicleSpeed is the only signal logged by accessing the Simulink.SimulationData.Dataset object sldemo_clutch_output.

    sim(mdl);
    sldemo_clutch_output
    sldemo_clutch_output = 
    Simulink.SimulationData.Dataset 'sldemo_clutch_output' with 1 element
    
                             Name          BlockPath                       
                             ____________  _______________________________ 
        1  [1x1 Signal]      VehicleSpeed  sldemo_clutch_override/Unlocked
    
      - 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.

    Action performed if verification fails, specified as 'error', 'warnAndRemove', or 'remove'. Specify one of the following values:

    • 'error' — Return an error when verification fails.

    • 'warnAndRemove' — Issue a warning when verification fails, and update the Simulink.SimulationData.ModelLoggingInfo object.

    • 'remove' — Silently update the Simulink.SimulationData.ModelLoggingInfo object.

    Version History

    Introduced in R2012b