zp2ss

Convert zero-pole-gain filter parameters to state-space form

Description

example

[A,B,C,D] = zp2ss(z,p,k) finds a state-space representation

$\begin{array}{l}\stackrel{˙}{x}=Ax+Bu\\ y=Cx+Du\end{array}$

such that it is equivalent to a system in factored transfer function form

$H\left(s\right)=\frac{Z\left(s\right)}{P\left(s\right)}=k\frac{\left(s-{z}_{1}\right)\left(s-{z}_{2}\right)\cdots \left(s-{z}_{n}\right)}{\left(s-{p}_{1}\right)\left(s-{p}_{2}\right)\cdots \left(s-{p}_{n}\right)}$

Column vector p specifies the pole locations, and matrix z the zero locations with as many columns as there are outputs. The gains for each numerator transfer function are in vector k. The A, B, C, and D matrices are returned in controller canonical form.

Examples

collapse all

Generate the state-space representation of a damped mass-spring system that obeys the differential equation

$\underset{}{\overset{¨}{w}}+0.01\underset{}{\overset{˙}{w}}+w=u\left(t\right).$

The measurable quantity is the acceleration, $y=\underset{}{\overset{¨}{w}}$, and $u\left(t\right)$ is the driving force. In Laplace space, the system is represented by

$Y\left(s\right)=\frac{{s}^{2}\phantom{\rule{0.2777777777777778em}{0ex}}U\left(s\right)}{{s}^{2}+0.01s+1}.$

The system has unit gain, a double zero at $s=0$, and two complex-conjugate poles.

z = [0 0];
p = roots([1 0.01 1])
p = 2×1 complex

-0.0050 + 1.0000i
-0.0050 - 1.0000i

k = 1;

Use zp2ss to find the state-space matrices.

[A,B,C,D] = zp2ss(z,p,k)
A = 2×2

-0.0100   -1.0000
1.0000         0

B = 2×1

1
0

C = 1×2

-0.0100   -1.0000

D = 1

Input Arguments

collapse all

Zeros of the system, specified as a vector. The zeros must be real or come in complex conjugate pairs.

Inf values may be used as place holders in z if some columns have fewer zeros than others.

Example: [1 (1+1j)/2 (1-1j)/2]'

Data Types: double
Complex Number Support: Yes

Poles of the system, specified as a vector. The poles must be real or come in complex conjugate pairs.

Example: [1 (1+1j)/2 (1-1j)/2]'

Data Types: double
Complex Number Support: Yes

Scalar gain of the system, specified as a scalar.

Data Types: double

Output Arguments

collapse all

State matrix, returned as a matrix. If the system is described by n state variables, then A is n-by-n.

Data Types: single | double

Input-to-state matrix, returned as a matrix. If the system is described by n state variables, then B is n-by-1.

Data Types: single | double

State-to-output matrix, returned as a matrix. If the system has q outputs and is described by n state variables, then C is q-by-n.

Data Types: single | double

Feedthrough matrix, returned as a matrix. If the system has q outputs, then D is q-by-1.

Data Types: single | double

Algorithms

zp2ss, for single-input systems, groups complex pairs together into two-by-two blocks down the diagonal of the A matrix. This requires the zeros and poles to be real or complex conjugate pairs.