Documentation Center

  • Trial Software
  • Product Updates


Convert symbolic expressions to Simscape language equations




simscapeEquation(f) converts the symbolic expression f to a Simscape™ language equation. This function call converts any derivative with respect to the variable t to the Simscape notation X.der. Here X is the time-dependent variable. In the resulting Simscape equation, the variable time replaces all instances of the variable t except for derivatives with respect to t.

simscapeEquation converts expressions with the second and higher-order derivatives to a system of first-order equations, introducing new variables, such as x1, x2, and so on.

simscapeEquation(LHS,RHS) returns a Simscape equation LHS == RHS.


Convert the following expressions to Simscape language equations.

syms t x(t) y(t);
phi = diff(x)+5*y + sin(t);
ans =
phi == sin(time)+y*5.0+x.der;

ans =
y.der == sin(time)+y*5.0+x.der;

Convert this expression containing the second derivative.

syms x(t)
eqn1 = diff(x,2) - diff(x) + sin(t);
ans =
x.der == x1;
  eqn1 == -x1+x1.der+sin(time);

Convert this expression containing the fourth and second derivatives.

eqn2 = diff(x,4) + diff(x,2) - diff(x) + sin(t);
ans =
x.der == x1;
  x1.der == x2;
  x2.der == x3;
  eqn2 == -x1+x2+sin(time)+x3.der;

More About

expand all


The equation section of a Simscape component file supports a limited number of functions. For details and the list of supported functions, see Simscape equations. If a symbolic equation contains the functions that are not available in the equation section of a Simscape component file, simscapeEquation cannot correctly convert these equations to Simscape equations. Such expressions do not trigger an error message. The following types of expressions are prone to invalid conversion:

  • Expressions with infinities

  • Expressions returned by evalin and feval.

If you perform symbolic computations in the MuPAD® Notebook app and want to convert the results to Simscape equations, use the generate::Simscape function in MuPAD.

See Also

| | |

Was this topic helpful?