Main Content

Simulink.sdi.isValidSignalID

Determine if signal ID is valid

Since R2022b

    Description

    example

    valid = Simulink.sdi.isValidSignalID(sigID) indicates whether sigID corresponds to a signal in the Simulation Data Inspector repository.

    Examples

    collapse all

    You can use the Simulink.sdi.isValidSignalID function to check whether a signal ID is valid.

    Simulate the model sldemo_fuelsys to create a run in the Simulation Data Inspector.

    mdl = "sldemo_fuelsys";
    sim(mdl)

    Use the Simulink.sdi.Run.getLatest function to access the latest run.

    fuelRun = Simulink.sdi.Run.getLatest;

    Get the signal ID for the first logged signal using the getSignalIDByIndex function.

    sigID = getSignalIDByIndex(fuelRun,1)
    sigID = int32
        2943
    

    Verify that the Simulation Data Inspector has a signal corresponding to the signal ID.

    Simulink.sdi.isValidSignalID(sigID)
    ans = logical
       1
    
    

    You can delete signals to clear out memory space or clean up the Simulation Data Inspector user interface.

    Simulink.sdi.deleteSignal(sigID)

    When you delete a signal, the signal ID becomes invalid.

    Simulink.sdi.isValidSignalID(sigID)
    ans = logical
       0
    
    

    Input Arguments

    collapse all

    Unique Simulation Data Inspector signal identifier, specified as a positive integer. The software creates a Simulink.sdi.Signal object for each signal you log in a model simulation or import into the Simulation Data Inspector. You can get the signal ID for a signal using getAllSignalIDs, getSignalIDsByName, or getSignalIDByIndex.

    Output Arguments

    collapse all

    Signal validity indicator, specified as a numeric or logical 1 (true) or 0 (false). When valid is true, the sigID is valid. When valid is false, the sigID is invalid.

    Version History

    Introduced in R2022b