Main Content

What Is the Simscape Language?

The Simscape™ language lets you create custom physical modeling components that do not exist in the Foundation library or in any of the add-on products. Simscape block libraries provide a comprehensive set of basic elements and specialized blocks. However, modeling physical systems often requires that you have complete control over the amount of detail contained in the model. Depending on your task, you may need to create additional blocks or add more detail to existing blocks, to balance the tradeoff of model fidelity and simulation speed.

For example, the Capacitor block in the Foundation library models a linear capacitor, described with the following equation:

I=CdVdt

where:

  • I is current.

  • C is capacitance.

  • V is voltage.

  • t is time.

If your model requires additional effects, for example, resistive losses, you can create a custom component based on a more complex equation:

Workflow diagram showing how to create a custom block based on desired equations

The Simscape language is a dedicated textual language for modeling physical systems and has the following characteristics:

  • Based on the MATLAB® programming language

  • Contains additional constructs specific to physical modeling

The Simscape language lets you define custom components as textual files, complete with parameterization, physical connections, and equations represented as acausal implicit differential algebraic equations (DAEs). The components you create can reuse the physical domain definitions provided with Simscape to ensure that your components are compatible with the standard Simscape components. For a detailed example, see Case Study — Basic Custom Block Library.

You can also add your own physical domains. For a detailed example, see Case Study — Electrochemical Library.

Simscape library blocks are also based on textual components authored using the Simscape language. To view the source files for Foundation library blocks, as well as for some blocks in the add-on products, double-click a block in the library to open its dialog box, click the Description tab, and then click the Source code link to open the Simscape source file for this block in the MATLAB Editor. You can use these source files as a basis for your custom components. Copy the file, save it under a different name, and then modify the equations and add the necessary parameters, variables, and intermediates. You can also use the Foundation library component files in your custom composite components. For more information, see Composite Components.

To deploy the textual component files in block diagrams, convert them into custom Simscape blocks. You can quickly transform a Simscape component file into a block in your model by using the Simscape Component block. You can also build custom block libraries of your Simscape components, enabling you to share these models across your organization. For more information on these two methods, see Generating Custom Blocks from Simscape Component Files.

Related Examples

More About