Method of mdss.
Simulate the time response of a discrete- or continuous-time implicit
MTI (mdss) model to arbitrary inputs.
Source: src/model/@mdss/msim.m
y = msim(sys, u, t, x0)
[y, tsim] = msim(sys, u, t, x0)
[y, tsim, x] = msim(sys, u, t, x0)
[y, tsim, x, z] = msim(sys, u, t, x0)
[y, tsim, x, z, tEvents] = msim(sys, u, t, x0)
[y, tsim, x, z, tEvents] = msim(sys, u, t, x0, y0, z0) % with initial guesses
[y, tsim, x, z, tEvents] = msim(sys, u, t, x0, [], [], opt) % with solver optionsRequest only the outputs you need — any of the left-hand sides above
works. The argument order is the same as for mss and
lsim: inputs, time, initial state. The initial guesses
y0 and z0 are optional and default to
[]; opt (continuous-time solver options)
follows them, so pass [], [] when you want solver options
but no guesses.
msim simulates the model sys. The solver is
selected automatically from sys.timeStepSize:
0 runs a continuous-time solve (MATLAB
ode15i), a positive value runs the discrete-time
solver.
The initial guesses for the algebraic
(y0) and binary (z0) signals may be left
empty:
y0 = [] → the solver tries both zeros and ones for the
algebraic signals.z0 = [] → the solver starts from zeros and searches for
a consistent binary combination.Otherwise y0 / z0 must have one entry per
algebraic / binary signal.
| Argument | Description |
|---|---|
sys |
The mdss model to simulate. |
u |
Input trajectory: one row per time sample, one column per input
(sys.nInput). Use [] for an autonomous
model. |
t |
Time samples of the input trajectory. For discrete-time models the
step dT must equal sys.timeStepSize. |
x0 |
Initial state values — one entry per state
(sys.nState). |
y0 |
(optional) Initial algebraic guess; []
(default) lets the solver search. |
z0 |
(optional) Initial binary guess; [] (default)
lets the solver search. |
opt |
(optional) solver options from odeset.
Continuous-time only. |
The order matches lsim and mss/msim: the non-state
signals first, then time, then the states.
| Output | Description |
|---|---|
y |
Simulated algebraic-signal trajectory. |
tsim |
Simulated time samples. |
x |
Simulated state trajectory. |
z |
Simulated binary-signal trajectory. |
tEvents |
Event times where binary signals switched. |
% Continuous-time model with one input
sys = stringParser.symbolicToMdss(["xp1 = -2*x1 + u1"; ...
"xp2 = x1 - x2"], 0);
t = (0:0.1:10).';
u = ones(numel(t), 1); % one column: sys.nInput == 1
x0 = [0 0];
opt = odeset('RelTol', 1e-5, 'AbsTol', 1e-7);
[~, tsim, x] = msim(sys, u, t, x0, [], [], opt);
plot(tsim, x); grid onFor fast-varying inputs, cap the solver step,
e.g. odeset('MaxStep', dt/2) where dt is the
smallest spacing between input samples.
opt is applied on top of the scheme defaults (for a
continuous-time mdss the default solver is
ode15i). It accepts two styles, and later
sources win in the order built-in standards → scheme default → your
opt:
odeset struct (AbsTol,
RelTol, MaxStep, …), andode()-style struct, which additionally lets you
pick the solver and set integrator-specific options.Passing a struct that selects the solver and non-standard integrator options:
opt = struct( ...
'Solver', "ode15i", ... % DAE solver (default for mdss)
'RelativeTolerance', 1e-6, ...
'AbsoluteTolerance', 1e-8, ...
'MaxStep', 0.05, ...
'MaxOrder', 2); % integrator-specific option
[~, tsim, x] = msim(sys, u, t, x0, [], [], opt);Recognised fields include Solver,
AbsoluteTolerance / AbsTol,
RelativeTolerance / RelTol,
InitialStep, MaxStep, MinStep,
MaxOrder, NormControl, OutputFcn,
OutputSelection and Vectorization. Unknown
field names are ignored.
mdss · symbolicToMdss
· c2d · d2d
MyToolbox Documentation | Generated automatically by CI/CD pipeline