pub struct StateSpace<F: Float, const VARCOUNT: usize>where
    [[F; VARCOUNT]; VARCOUNT]: SquareMatrix,
    [[F; 1]; VARCOUNT]: Matrix,
    [[F; VARCOUNT]; 1]: Matrix,
{ pub a: [[F; VARCOUNT]; VARCOUNT], pub b: [[F; 1]; VARCOUNT], pub c: [[F; VARCOUNT]; 1], pub d: F, }
Expand description

State-space equation matrices A, B, C and D contained in one structure

Fields§

§a: [[F; VARCOUNT]; VARCOUNT]§b: [[F; 1]; VARCOUNT]§c: [[F; VARCOUNT]; 1]§d: F

Implementations§

Creates a new state-space struct in control-canonical form

Arguments
  • a - Transfer function denominator polynomial
  • b - Transfer function enumerator polynomial
Examples
let a = [1.0, 2.0, 3.0];
let b = [4.0, 5.0, 6.0];
 
let ss = StateSpace::new_control_canonical_form(a, b);
 
assert_eq!(ss.a, [
    [-a[0], -a[1], -a[2]],
    [1.0, 0.0, 0.0],
    [0.0, 1.0, 0.0]
]);
assert_eq!(ss.b, [
    [1.0],
    [0.0],
    [0.0]
]);
assert_eq!(ss.c, [
    [b[0], b[1], b[2]]
]);
assert_eq!(ss.d, 0.0);

Creates a new state-space struct in observer-canonical form

Arguments
  • a - Transfer function denominator polynomial
  • b - Transfer function enumerator polynomial
Examples
let a = [1.0, 2.0, 3.0];
let b = [4.0, 5.0, 6.0];
 
let ss = StateSpace::new_observer_canonical_form(a, b);
 
assert_eq!(ss.a, [
    [-a[0], 1.0, 0.0],
    [-a[1], 0.0, 1.0],
    [-a[2], 0.0, 0.0]
]);
assert_eq!(ss.b, [
    [b[0]],
    [b[1]],
    [b[2]]
]);
assert_eq!(ss.c, [
    [1.0, 0.0, 0.0]
]);
assert_eq!(ss.d, 0.0);

Returns the controllability-matrix of the state-space equation

𝒞

Examples
let cc = ss.controllability()

Checks if the controllability-matrix is nonzero

det(𝒞) != 0

Examples
ss.is_controllable()

Returns the observability-matrix of the state-space equation

𝒪

Examples
let cc = ss.observability()

Checks if the observability-matrix is nonzero

det(𝒪) != 0

Examples
ss.is_observable()

Transforms the form of the state-space system by a transformation matrix

A’ = T⁻¹AT

B’ = T⁻¹B

C’ = CT

D’ = D

Arguments
  • t - The transformation matrix
Examples
let sst = ss.transform_state(t)

Transforms any state-space system into control-canonical form

Examples
let ssc = ss.transform_into_control_canonical_form()

Transforms any state-space system into observer-canonical form

Examples
let sso = ss.transform_into_observer_canonical_form()

Returns the derivative of the internal variables according to the state-space equations

Arguments
  • x - The state of the internal state-space variables organized in a collumn-vector
  • u - The system input state
Examples
let dt = 0.0001;
let mut x = [
    [0.0],
    [0.0]
];
let mut u = 0.0;
for _ in 0..10000
{
    x = x.add(ss.dxdt(x, u).mul(dt))
    u = 1.0;
}
let y_ss = ss.y(x, u);
// Steady state error:
let e_ss = y_ss - u;

Returns the output state according to the state-space equations

Arguments
  • x - The state of the internal state-space variables organized in a collumn-vector
  • u - The system input state
Examples
let dt = 0.0001;
let mut x = [[0.0]; 2];
let mut u = 0.0;
for _ in 0..10000
{
    x = x.add(ss.dxdt(x, u).mul(dt));
    u = 1.0;
}
let y_ss = ss.y(x, u);
// Steady state error:
let e_ss = y_ss - u;

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.