Transformation of a representation in the state space into a transfer function.
Library
EngeeDSP
Syntax
Function call
b,a = ss2tf(A,B,C,D) — transforms the representation of the system in the state space into an equivalent transfer function. Function ss2tf returns the transfer function of the Laplace transform for continuous-time systems and the transfer function of the Z-transform for discrete-time systems.
b,a = ss2tf(A,B,C,D,ni) — returns the transfer function that is obtained when excited by a single pulse ni-th input of a system with multiple inputs.
The end-to-end transmission matrix, defined as a matrix. If the system has entrances and outputs and is described state variables, then D has a size of on .
The index of the input, set as an integer scalar. If the system has inputs, use the function ss2tf with an argument ni to calculate the response to a single pulse applied to ni- I’m coming in.
Типы данных
Int32, Int64
Output arguments
#b —
coefficients of the numerator of the transfer function
+
vector | the matrix
Details
The coefficients of the numerator of the transfer function, returned as a vector or matrix. If the system has entrances and outputs and is described state variables, then b It has a size on for each entrance. The coefficients are returned in descending order of degrees or .
#a —
coefficients of the denominator of the transfer function
+
vector
Details
The coefficients of the denominator of the transfer function, returned as a vector. If the system has entrances and outputs and is described state variables, then a has a size of on for each entrance. The coefficients are returned in descending order of degrees or .
Examples
Mass-spring system
Details
A one-dimensional oscillatory system with discrete time consists of a single mass , attached to the wall by a spring with a unit elastic constant . The sensor registers acceleration masses with frequency Hz.
Generate 50 time counts. Let’s define the sampling interval .
Fs = 5
dt = 1 / Fs
N = 50
t = dt * (0:N-1)
The oscillator can be described by the equations of the state space:
where is the state vector, and — the position and velocity of the mass, respectively, and the matrix
A = [cos(dt) sin(dt); -sin(dt) cos(dt)]
B = [1-cos(dt); sin(dt)]
C = [-1 0]
D = 1
The system is excited by a single pulse in the positive direction. We use the state space model to calculate the time evolution of the system, starting from the zero initial state.
u = [1.0; zeros(N-1)]
x = [0; 0]
y = zeros(N)
for k = 1:N
y[k] = (C * x)[1] + D * u[k]
global x = A * x + B * u[k]
end
Let’s plot the dependence of mass acceleration on time.
An ideal one-dimensional oscillatory system consists of two unit masses and enclosed between two walls. Each mass is attached to the nearest wall by a spring with a unit elastic constant . Another spring of the same type connects the two masses. Sensors register mass accelerations and , with frequency Hz.
Setting the total measurement time 16 c. Define the sampling interval .
Fs = 16
dt = 1 / Fs
N = 257
t = dt * (0:N-1)
The system can be described using a state space model.:
where — the vector of the state, and and — position and speed -th mass, respectively. The input vector and the output vector . State space matrices:
where , — continuous-time state space matrices:
but denotes a unit matrix of the appropriate size.
using LinearAlgebra
Ac = [0 1 0 0; -2 0 1 0; 0 0 0 1; 1 0 -2 0]
A = exp(Ac * dt)
Bc = [0 0; 1 0; 0 0; 0 1]
B = Ac \ (A - I(4)) * Bc
C = [-2 0 1 0; 1 0 -2 0]
D = I(2)
The first mass receives a single pulse in a positive direction.
We transform the system into a representation in the form of a transfer function. Let’s find the response of the system to a positive single impulse action on the first mass.
The system returns to its original state. Now another mass, , receives a single pulse in the positive direction. Let’s calculate the time evolution of the system.
u = [u0; ux]
x = zeros(4)
for k = 1:N
y[:, k] = C * x + D * u[:, k]
global x = A * x + B * u[:, k]
end
Let’s plot the acceleration graph. The responses of individual masses have changed places.