This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

subsystem2ssc

Convert subsystem containing Simscape blocks into equivalent Simscape file or files

Syntax

subsystem2ssc(subsystem)
subsystem2ssc(subsystem,targetFolder)

Description

example

subsystem2ssc(subsystem) converts a subsystem consisting entirely of Simscape™ blocks into a single Simscape component file, located in the current working folder. The function generates a composite component file based on the subsystem configuration. If the subsystem being converted contains nested subsystems, then the function generates several Simscape files, one for each subsystem.

You can mark member block and subsystem parameters for promotion to the top level, and the function automatically generates the corresponding code, similar to composite components. For more information, see Promote Underlying Parameters to Subsystem Mask (Simulink).

The subsystem being converted cannot contain blocks from the Simscape Utilities library (such as Solver Configuration, PS-Simulink Converter, Simulink-PS Converter, Simscape Bus, and so on) because they are not authored in Simscape language and therefore have no equivalent textual representation. The exception is the Connection Port block, because it can be represented by the connect statements in Simscape language. If the subsystem contains a Simscape Component block, then during the conversion this block is replaced by its source component.

example

subsystem2ssc(subsystem,targetFolder) converts a subsystem containing Simscape blocks into equivalent Simscape component file, or files, located in targetFolder.

Examples

collapse all

Open the DC Motor example model.

ssc_dcmotor

This example model contains a subsystem named DC Motor. Convert this subsystem into a Simscape component file and place this file in your current working folder.

subsystem2ssc('ssc_dcmotor/DC Motor')

The function creates a file named DC_Motor.ssc in the current folder. Open the file in the editor.

open DC_Motor.ssc

Double-click the DC Motor subsystem in the example model and compare it to the generated file. The generated composite component contains the same components, parameters, and connections as the original subsystem.

Open the DC Motor example model.

ssc_dcmotor

This example model contains a subsystem named DC Motor. Convert this subsystem into a Simscape component file and place the generated file in a designated folder.

subsystem2ssc('ssc_dcmotor/DC Motor','./MotorsLibrary')

The function creates a file named DC_Motor.ssc and places it into the folder named MotorsLibrary.

If the specified target folder does not exist, the function creates it.

Input Arguments

collapse all

Subsystem name or identifier, specified as a block handle or a full name, including the path to the subsystem from the root of the model.

Example: 'ssc_dcmotor/DC Motor'

Data Types: double | char | string

Location of generated component files, specified as a character vector or string scalar. The function places the generated component files in this folder. If the folder does not exist, the function creates it.

Example: './files'

Data Types: char | string

Introduced in R2018b