Main Content

Simulink.SubsystemReference.convertSubsystemToSubsystemReference

Convert Subsystem block to Subsystem Reference block

Since R2022a

    Description

    Simulink.SubsystemReference.convertSubsystemToSubsystemReference(ssBlock,ssFile) converts the Subsystem block ssBlock in a model or library to a Subsystem Reference block and saves the subsystem content in a subsystem file ssFile. The function returns a logical 1 (true) on successful conversion. Otherwise, an error message is displayed.

    example

    Examples

    collapse all

    Open the model sldemo_mdlref_conversion, which has a Subsystem block Bus Counter that models a counter algorithm.

    open_system("sldemo_mdlref_conversion");

    Convert the Subsystem block Bus Counter to a Subsystem Reference block and save the subsystem contents in a subsystem file Bus_Counter.

    Simulink.SubsystemReference.convertSubsystemToSubsystemReference...
        ('sldemo_mdlref_conversion/Bus Counter','Bus_Counter')
    ans = logical
       1
    
    

    The Subsystem block is converted to a Subsystem Reference block with the name of the subsystem file Bus_Counter displayed at the top of the block icon. The subsystem file contains the Bus Counter subsystem and is saved in the current folder.

    Input Arguments

    collapse all

    Path or handle of a Subsystem block in a model or library, specified as a string scalar or character vector.

    Example: "sldemo_mdlref_conversion/Bus Counter"

    Data Types: string | char

    Name of a new subsystem file that stores the subsystem contents after conversion, specified as a character vector. The subsystem file is saved in the current folder.

    Example: 'slexReusableSS'

    Data Types: char

    Alternatives

    You can convert a Subsystem block to a Subsystem Reference block from the Simulink® toolstrip. For more information, see Convert Subsystem to a Referenced Subsystem.

    Version History

    Introduced in R2022a