Main Content

Simulink.SubsystemReference.getNearestParentSubsystemReferenceBlock

Return nearest parent Subsystem Reference block for specified block

Since R2022a

    Description

    ssRefBlock = Simulink.SubsystemReference.getNearestParentSubsystemReferenceBlock(blockPath) returns the nearest parent Subsystem Reference block for the specified block. If the specified block is not inside any Subsystem Reference block, the function returns an empty array.

    example

    Examples

    collapse all

    Load the model slexModelUsingReusableSS containing referenced subsystems.

    load_system("slexModelUsingReusableSS");

    Get the block handle for which you want to find the parent Subsystem Reference block.

    blk = 'slexModelUsingReusableSS/Double Input/Amplify Signal';
    open_system(blk);

    Get the path of the nearest parent Subsystem Reference block of blk.

    Simulink.SubsystemReference.getNearestParentSubsystemReferenceBlock(blk)
    ans = 
    'slexModelUsingReusableSS/Double Input'
    

    Input Arguments

    collapse all

    Path or handle of a block, specified as a string scalar or character vector for a path and double for a handle.

    Example: "slexModelUsingReusableSS/Double Input/Amplify Signal"

    Data Types: string | char | double

    Output Arguments

    collapse all

    Path or handle of the nearest parent Subsystem Reference block, returned as a character vector or double. If the specified block is not inside any Subsystem Reference block, the function returns an empty array. The type of output depends on the input type. If you specify the path of block, the function returns the path of its nearest parent Subsystem Reference block.

    Version History

    Introduced in R2022a