Method of stringParser.
Build an mdss model
from symbolic or string equations.
Source: src/utilities/@stringParser/symbolicToMdss.m
sys = stringParser.symbolicToMdss(eq, Ts)
sys = stringParser.symbolicToMdss(eq, Ts, symbols)
sys = stringParser.symbolicToMdss(eq, Ts, symbols, symbolicParameters, numericParameters)symbolicToMdss parses a set of equations into an
mdss object, building the structure and parameter matrices
and the signal index vectors automatically.
Each equation may be written in any form (0 = …, or a
polynomial on both sides); it is rearranged into the implicit form
0 = h(…) internally. Multiplication must be explicit
(a*x1, not a x1). Allowed operators are
* + - / ^ and parentheses. Inequalities
(>=, <=) become inequality rows.
Integer powers are supported: the parser introduces
auxiliary algebraic variables and equations to reduce any power to a
multilinear product (so x1^3 becomes a chain of products).
Because powers are handled structurally, exponents cannot be identified
as parameters.
The third argument maps each variable role to its symbol prefix, in the order
[stateDelta, state, input, algebraic, binary]
with default ["xp", "x", "u", "y", "z"]. Different
variables of one role are distinguished by an integer index
(x1, x2, …). Any token that is not one of the
role symbols is treated as a parameter.
You may supply fewer symbols: the list is taken as a
prefix of the five roles and the missing trailing roles keep their
defaults. For example ["xp","x"] parses a pure ODE system
with no inputs, algebraic or binary variables.
Symbolic parameters and their numeric values are passed inline as the fourth and fifth arguments; the returned model is then ready to simulate. Omitting them keeps the parameters symbolic (useful for inspection, but they must be replaced with numbers before simulation).
| Argument | Description |
|---|---|
eq |
Equations as a string / symbolic array (or cell). |
Ts |
Sample time: 0 continuous-time, >0
discrete-time. |
symbols |
(optional) role symbols, default
["xp","x","u","y","z"]. |
symbolicParameters |
(optional) symbolic parameters to substitute. |
numericParameters |
(optional) numeric values, aligned with
symbolicParameters. |
Continuous-time model with named parameters supplied inline:
eq = ["xp1 = a*x2*x3"; ...
"xp2 = x1 - b*x2"; ...
"xp3 = c - x1*x2"];
sys = stringParser.symbolicToMdss( ...
eq, 0, ["xp","x","u","y","z"], ...
sym(["a","b","c"]), [0.4, 1.2, 1]);Fewer symbols for a pure ODE (no inputs/algebraic/binary), leaving a parameter symbolic:
sys = stringParser.symbolicToMdss(["xp1 = x2"; "xp2 = -k*x1"], 0, ["xp","x"]);Custom role symbols:
eq = ["out1*in1 = x1*in3"; "xp1 = in1 - x1"];
sys = stringParser.symbolicToMdss(eq, 0, ["xp","x","in","out"]);mdss · stringToMdss
· polynomialToMdss
· symbolicEquations
Authors: Torben Warnecke, Nicholas Tedjosantoso.
MyToolbox Documentation | Generated automatically by CI/CD pipeline