#[non_exhaustive]pub struct ZerosPolesGain {
pub zeros: Vec<Complex<f64>>,
pub poles: Vec<Complex<f64>>,
pub gain: f64,
pub dt: Option<f64>,
}Expand description
A single-input, single-output system H = k ∏(x − zᵢ) / ∏(x − pⱼ) with x = s in
continuous time (dt = None) or x = z in discrete time with sample time dt (SciPy’s
ZerosPolesGain and lti(z, p, k) / dlti(z, p, k, dt=dt)). Complex zeros and poles must
come in conjugate pairs for the real-coefficient conversions.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.zeros: Vec<Complex<f64>>§poles: Vec<Complex<f64>>§gain: f64§dt: Option<f64>The sample time of a discrete-time system; None in continuous time.
Implementations§
Source§impl ZerosPolesGain
impl ZerosPolesGain
Sourcepub fn new(
zeros: Vec<Complex<f64>>,
poles: Vec<Complex<f64>>,
gain: f64,
) -> Self
pub fn new( zeros: Vec<Complex<f64>>, poles: Vec<Complex<f64>>, gain: f64, ) -> Self
A continuous-time system.
Sourcepub fn new_discrete(
zeros: Vec<Complex<f64>>,
poles: Vec<Complex<f64>>,
gain: f64,
dt: f64,
) -> Result<Self, ErrorsJSL>
pub fn new_discrete( zeros: Vec<Complex<f64>>, poles: Vec<Complex<f64>>, gain: f64, dt: f64, ) -> Result<Self, ErrorsJSL>
A discrete-time system with sample time dt > 0.
Sourcepub fn from_tf(
num: &[f64],
den: &[f64],
dt: Option<f64>,
) -> Result<Self, ErrorsJSL>
pub fn from_tf( num: &[f64], den: &[f64], dt: Option<f64>, ) -> Result<Self, ErrorsJSL>
From a transfer function num/den (highest power first), through tf2zpk.
Sourcepub fn from_ss(
sys: &ContinuousStateSpace,
dt: Option<f64>,
) -> Result<Self, ErrorsJSL>
pub fn from_ss( sys: &ContinuousStateSpace, dt: Option<f64>, ) -> Result<Self, ErrorsJSL>
From a single-input, single-output state-space model.
Sourcepub fn to_tf(&self) -> (Vec<f64>, Vec<f64>)
pub fn to_tf(&self) -> (Vec<f64>, Vec<f64>)
The transfer function (num, den), highest power first (SciPy’s to_tf).
Sourcepub fn to_ss(&self) -> Result<ContinuousStateSpace, ErrorsJSL>
pub fn to_ss(&self) -> Result<ContinuousStateSpace, ErrorsJSL>
A state-space realisation in controllable canonical form (SciPy’s to_ss). For a
discrete-time system the matrices are those of x[k+1] = A x[k] + B u[k].
Sourcepub fn freqresp(&self, w: &[f64]) -> Vec<Complex<f64>>
pub fn freqresp(&self, w: &[f64]) -> Vec<Complex<f64>>
The frequency response at the angular frequencies w: H(iω) in continuous time
(rad/s), H(e^{iω}) in discrete time (rad/sample, as SciPy’s dfreqresp), evaluated
factor by factor.
Sourcepub fn bode(&self, w: &[f64]) -> (Vec<f64>, Vec<f64>)
pub fn bode(&self, w: &[f64]) -> (Vec<f64>, Vec<f64>)
The Bode diagram: 20 log₁₀|H| in dB and the unwrapped phase in degrees (SciPy’s bode
and dbode; in discrete time w is in rad/sample).
Sourcepub fn lsim(
&self,
u: &[f64],
t: &[f64],
hold: InputHold,
) -> Result<Vec<f64>, ErrorsJSL>
pub fn lsim( &self, u: &[f64], t: &[f64], hold: InputHold, ) -> Result<Vec<f64>, ErrorsJSL>
The response to the input samples u at equally spaced times t from rest, with the
input held or interpolated between samples (SciPy’s lsim). Continuous time only.
Sourcepub fn step(&self, t: &[f64]) -> Result<Vec<f64>, ErrorsJSL>
pub fn step(&self, t: &[f64]) -> Result<Vec<f64>, ErrorsJSL>
The step response at times t (SciPy’s step). Continuous time only.
Sourcepub fn impulse(&self, t: &[f64]) -> Result<Vec<f64>, ErrorsJSL>
pub fn impulse(&self, t: &[f64]) -> Result<Vec<f64>, ErrorsJSL>
The impulse response at times t (SciPy’s impulse). Continuous time only.
Sourcepub fn dlsim(&self, u: &[f64]) -> Result<Vec<f64>, ErrorsJSL>
pub fn dlsim(&self, u: &[f64]) -> Result<Vec<f64>, ErrorsJSL>
The response to the samples u from rest (SciPy’s dlsim). Discrete time only.
Sourcepub fn dstep(&self, n: usize) -> Result<Vec<f64>, ErrorsJSL>
pub fn dstep(&self, n: usize) -> Result<Vec<f64>, ErrorsJSL>
The first n samples of the step response (SciPy’s dstep). Discrete time only.
Sourcepub fn dimpulse(&self, n: usize) -> Result<Vec<f64>, ErrorsJSL>
pub fn dimpulse(&self, n: usize) -> Result<Vec<f64>, ErrorsJSL>
The first n samples of the response to a unit pulse at k = 0 (SciPy’s dimpulse).
Discrete time only.
Sourcepub fn to_discrete(
&self,
dt: f64,
method: Discretization,
) -> Result<ZerosPolesGain, ErrorsJSL>
pub fn to_discrete( &self, dt: f64, method: Discretization, ) -> Result<ZerosPolesGain, ErrorsJSL>
The discrete-time system for sample time dt (SciPy’s to_discrete, i.e.
cont2discrete on the state-space form and back).