Main Content

simscapeEquation

Convert symbolic expressions toSimscapelanguage equations

Description

example

simscapeEquation(f)converts the symbolic expressionfto a Simscape™ language equation. This function call converts any derivative with respect to the variabletto the Simscape notationX.der. HereXis the time-dependent variable. In the resulting Simscape equation, the variabletimereplaces all instances of the variabletexcept for derivatives with respect tot.

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

example

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

Examples

collapse all

Convert the following expressions to Simscape language equations.

syms t x(t) y(t) phi = diff(x) + 5*y + sin(t); simscapeEquation(phi) simscapeEquation(diff(y),phi)
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); simscapeEquation(eqn1)
ans = 'x.der == x1; eqn1 == sin(time)-x1+x1.der;'

Convert this expression containing the fourth and second derivatives.

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

Tips

  • The equation section of a Simscape component file supports a limited number of functions. For details and the list of supported functions, see Simscapeequations(Simscape). If a symbolic equation contains functions that are not available in the equation section of a Simscape component file,simscapeEquationcannot convert these equations correctly to Simscape equations. Such expressions do not trigger an error message. Expressions with infinities are prone to invalid conversion.

Introduced in R2010a