pub struct StateSpace {
pub a: C2D,
pub b: C2D,
pub c: C2D,
pub d: C2D,
pub x: C1D,
/* private fields */
}Expand description
Discrete-time state-space model using complex-valued matrices and vectors.
The state evolves as x[k+1] = A x[k] + B u[k]. The output follows one of two conventions
(see OutputConvention):
new_standard:y[k] = C x[k] + D u[k], the textbook and SciPy model;new:y[k] = C x[k+1] + D u[k], the state updated before the output is read, which matches the C++ implementation that this type mirrors.
All matrices use C2D and all vectors use C1D, so real-valued models
can be represented as purely real complex matrices while still allowing
complex-valued systems when needed.
Fields§
§a: C2DState-transition matrix.
b: C2DInput-to-state matrix.
c: C2DState-to-output matrix.
d: C2DInput-to-output feedthrough matrix.
x: C1DCurrent state vector.
Implementations§
Source§impl StateSpace
impl StateSpace
Sourcepub fn new(a: C2D, b: C2D, c: C2D, d: C2D, x: C1D) -> Result<Self, ErrorsJSL>
pub fn new(a: C2D, b: C2D, c: C2D, d: C2D, x: C1D) -> Result<Self, ErrorsJSL>
Construct a model that reads its output after updating the state,
y[k] = C x[k+1] + D u[k] (OutputConvention::Updated). For the textbook and SciPy
convention use new_standard.
The dimensions must satisfy:
Aisn x nBisn x pCism x nDism x pxhas lengthn
Sourcepub fn new_standard(
a: C2D,
b: C2D,
c: C2D,
d: C2D,
x: C1D,
) -> Result<Self, ErrorsJSL>
pub fn new_standard( a: C2D, b: C2D, c: C2D, d: C2D, x: C1D, ) -> Result<Self, ErrorsJSL>
Construct a model in the textbook and SciPy convention,
x[k+1] = A x[k] + B u[k], y[k] = C x[k] + D u[k]: each step reads the
output from the current state and then updates it. A model given to
scipy.signal.dlsim as (A, B, C, D) is entered here unchanged.
Sourcepub fn with_convention(
a: C2D,
b: C2D,
c: C2D,
d: C2D,
x: C1D,
convention: OutputConvention,
) -> Result<Self, ErrorsJSL>
pub fn with_convention( a: C2D, b: C2D, c: C2D, d: C2D, x: C1D, convention: OutputConvention, ) -> Result<Self, ErrorsJSL>
Construct a model with an explicit OutputConvention; the dimensions are as for
new.
Sourcepub fn convention(&self) -> OutputConvention
pub fn convention(&self) -> OutputConvention
The output convention of this model.
Sourcepub fn to_standard(&self) -> StateSpace
pub fn to_standard(&self) -> StateSpace
Sourcepub fn step(&mut self, u: C1D) -> Result<C1D, ErrorsJSL>
pub fn step(&mut self, u: C1D) -> Result<C1D, ErrorsJSL>
Advance the system by one discrete input sample and return the output.
In the standard convention, y <- C x + D u and then x <- A x + B u; in the updated
convention (the C++ ordering), x <- A x + B u first and then y <- C x + D u.
Sourcepub fn is_observable(&self) -> Result<bool, ErrorsJSL>
pub fn is_observable(&self) -> Result<bool, ErrorsJSL>
Check whether the discrete-time model is observable.
The observability matrix is formed by vertically stacking
C, C A, C A^2, ..., C A^(n-1).
Sourcepub fn is_controllable(&self) -> Result<bool, ErrorsJSL>
pub fn is_controllable(&self) -> Result<bool, ErrorsJSL>
Check whether the discrete-time model is controllable.
The controllability matrix is formed by horizontally stacking
B, A B, A^2 B, ..., A^(n-1) B.