pub struct ContinuousStateSpace {
pub a: Array2<f64>,
pub b: Array2<f64>,
pub c: Array2<f64>,
pub d: Array2<f64>,
}Expand description
A continuous-time state-space model with real matrices (SciPy’s StateSpace with dt=None).
Fields§
§a: Array2<f64>§b: Array2<f64>§c: Array2<f64>§d: Array2<f64>Implementations§
Source§impl ContinuousStateSpace
impl ContinuousStateSpace
Sourcepub fn new(
a: Array2<f64>,
b: Array2<f64>,
c: Array2<f64>,
d: Array2<f64>,
) -> Result<Self, ErrorsJSL>
pub fn new( a: Array2<f64>, b: Array2<f64>, c: Array2<f64>, d: Array2<f64>, ) -> Result<Self, ErrorsJSL>
A model from its matrices, checking that the shapes agree.
Sourcepub fn lsim(
&self,
u: &Array2<f64>,
t: &[f64],
x0: Option<&[f64]>,
hold: InputHold,
) -> Result<Simulation, ErrorsJSL>
pub fn lsim( &self, u: &Array2<f64>, t: &[f64], x0: Option<&[f64]>, hold: InputHold, ) -> Result<Simulation, ErrorsJSL>
Simulates the response to the input samples u (one row per time) at equally spaced
times t, from the initial state x0 (zero if None) (SciPy’s lsim).
The input is held constant (InputHold::Zero) or interpolated linearly
(InputHold::Linear) between samples, and each step is then exact: with
M = [[A T, B T, 0], [0, 0, I], [0, 0, 0]] and e^M’s top blocks Φ, Γ₁, Γ₂,
x[i+1] = Φ x[i] + (Γ₁ − Γ₂) u[i] + Γ₂ u[i+1].
Sourcepub fn step(&self, t: &[f64], input: usize) -> Result<Array2<f64>, ErrorsJSL>
pub fn step(&self, t: &[f64], input: usize) -> Result<Array2<f64>, ErrorsJSL>
The step response from input input at times t (SciPy’s step, with a zero-order hold).
Sourcepub fn impulse(&self, t: &[f64], input: usize) -> Result<Array2<f64>, ErrorsJSL>
pub fn impulse(&self, t: &[f64], input: usize) -> Result<Array2<f64>, ErrorsJSL>
The impulse response C e^{At} B from input input at times t (SciPy’s impulse,
which leaves out the D δ(t) term).
Sourcepub fn freqresp(
&self,
w: &[f64],
) -> Result<Vec<Array2<Complex<f64>>>, ErrorsJSL>
pub fn freqresp( &self, w: &[f64], ) -> Result<Vec<Array2<Complex<f64>>>, ErrorsJSL>
The frequency response H(iω) = C (iω I − A)⁻¹ B + D at each angular frequency, one
p × m matrix per frequency.
Sourcepub fn bode(
&self,
w: &[f64],
input: usize,
output: usize,
) -> Result<(Vec<f64>, Vec<f64>), ErrorsJSL>
pub fn bode( &self, w: &[f64], input: usize, output: usize, ) -> Result<(Vec<f64>, Vec<f64>), ErrorsJSL>
The Bode diagram from input input to output output (SciPy’s bode): the magnitude
20 log₁₀ |H(iω)| in dB and the unwrapped phase in degrees.
Sourcepub fn discretize(
&self,
dt: f64,
method: Discretization,
) -> Result<DiscreteMatrices, ErrorsJSL>
pub fn discretize( &self, dt: f64, method: Discretization, ) -> Result<DiscreteMatrices, ErrorsJSL>
The discrete-time system for sample time dt (SciPy’s cont2discrete).