c2d

Method of mdss.

Convert a continuous-time mdss model to discrete time.

Source: src/model/@mdss/c2d.m

Syntax

sysd = c2d(sysc, Ts)
sysd = c2d(sysc, Ts, method)

Description

c2d discretizes the continuous-time model sysc (which must have timeStepSize == 0) with sample time Ts > 0. The state derivative is replaced by a finite-difference approximation, which is implemented by manipulating the structure and parameter matrices directly: an auxiliary variable and equation are added for each state, and any that can be eliminated algebraically are removed via algebraicElimination. The result carries timeStepSize = Ts and records the chosen discretizationType.

The method selects the approximation:

method Rule
"forward" (default) Forward Euler: ẋ(xk+1xk)/Ts\dot{x} \approx (x_{k+1} - x_k)/T_s
"backward" Backward Euler
"tustin" Trapezoidal — not yet implemented

Input arguments

Argument Description
sysc Continuous-time mdss model (timeStepSize == 0).
Ts Discrete sample time, Ts > 0.
method (optional) "forward" (default), "backward", or "tustin".

Output arguments

Output Description
sysd Discrete-time mdss model with timeStepSize = Ts, the state derivative replaced by the chosen one-step Euler update, and eliminable auxiliary equations removed.

Example

sysc = stringParser.symbolicToMdss(["xp1 = x2"; ...
                                    "xp2 = -x1 - 0.5*x2"], 0);

sysd  = c2d(sysc, 0.1);              % forward Euler
sysdb = c2d(sysc, 0.1, "backward");  % backward Euler

See also

d2c · d2d · mdss · msim


MyToolbox Documentation | Generated automatically by CI/CD pipeline