Component Equations

Write equations to represent custom component behavior

Simscape Language Syntax

assertProgram customized run-time errors and warnings
delayReturn past value of operand
derReturn time derivative of operand
equationsDefine component equations
functionReuse expressions in component equations and in member declarations of domains and components
integPerform time integration of expression
tablelookupReturn value based on interpolating set of data points
timeAccess global simulation time
valueConvert variable or parameter to unitless value with specified unit conversion

Examples and How To

Simple Algebraic System

This example shows implementation for a simple algebraic system:

Use Simulation Time in Equations

You can access global simulation time from the equation section using the time function.

Import Symbolic Math Toolbox Equations

Example of using Symbolic Math Toolbox™ software to solve the physical equations, generate code in the format appropriate for the Simscape™ language equation section, and incorporate the generated code into the equation section of a component file.


Defining Component Equations

The equation section of a Simscape file is executed throughout the simulation.

Using Conditional Expressions in Equations

You can specify conditional equations by using if statements.

Using Intermediate Terms in Equations

Textbooks often define certain equation terms in separate equations, and then substitute these intermediate equations into the main one.

Using Lookup Tables in Equations

You can use the tablelookup function in the equations section of the Simscape file to interpolate input values based on a set of data points in a one-dimensional, two-dimensional , or three-dimensional table.

Programming Run-Time Errors and Warnings

Use the assert construct to implement run-time error and warning messages for a custom block.

Simscape Functions

Use Simscape functions to reuse expressions in equations and member declarations of multiple components.

Was this topic helpful?