Main Content

Simulink.sdi.removeTrigger

Remove trigger from signal in the Simulation Data Inspector

Since R2020b

    Description

    example

    Simulink.sdi.removeTrigger removes the trigger from a signal in the Simulation Data Inspector. If a trigger exists in the Simulation Data Inspector, adding a trigger to a different signal also removes the existing trigger.

    Examples

    collapse all

    Add a trigger to a signal in the Simulation Data Inspector to specify criteria that determine when to update plots to display fresh data. Triggers can allow you to capture transient signal behavior and can help stabilize the display of periodic signals so you can take measurements.

    Simulate the Triggers model. Data in the model logs to the Simulation Data Inspector.

    open_system('Triggers');
    out = sim('Triggers');

    Then, add a trigger to the Pulse signal. Configure the trigger as a falling-edge trigger with a threshold of 0.5.

    trigRun = Simulink.sdi.getCurrentSimulationRun('Triggers');
    pulseSig = getSignalsByName(trigRun,'Pulse');
    Simulink.sdi.addTrigger(pulseSig,'Type','Edge','Level',0.5);

    You can verify that the trigger was added and configured correctly by opening the Simulation Data Inspector using Simulink.sdi.view and clicking the trigger icon next to the Pulse signal to check the configuration. You can also use the Simulink.sdi.getTrigger function to check which signal is used to generate trigger events and the trigger configuration.

    [sig,trigOpts] = Simulink.sdi.getTrigger;
    
    sig.Name
    ans = 
    'Pulse'
    
    trigOpts
    trigOpts = struct with fields:
                           Mode: 'Auto'
                           Type: 'Edge'
                       Position: 0.5000
                          Delay: 0
        SourceChannelComplexity: 'Scalar'
                       Polarity: 'Positive'
                      AutoLevel: 1
                          Level: 0.5000
                     UpperLevel: 0
                     LowerLevel: 4.6673e-62
                     Hysteresis: 0
                        MinTime: 0
                        MaxTime: Inf
                        Timeout: 0
                        Holdoff: 0
    
    

    When you do not want to use a trigger to control when the Simulation Data Inspector updates the plots with fresh data, you can remove the trigger using the Simulink.sdi.removeTrigger function.

    Simulink.sdi.removeTrigger

    You can verify that the trigger was removed in the Simulation Data Inspector UI or using the Simulink.sdi.getTrigger function. The Simulink.sdi.getTrigger function returns an empty array of Simulink.sdi.Signal objects when no trigger is configured in the Simulation Data Inspector.

    sig = Simulink.sdi.getTrigger;
    size(sig)
    ans = 1×2
    
         0     0
    
    

    Alternative Functionality

    To remove a trigger from a signal using the Simulation Data Inspector UI, click the trigger symbol next to the signal, then click Remove.

    Version History

    Introduced in R2020b