Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
ss2tf
Convert state-space representation to transfer function
Syntax
[b,a] = ss2tf(A,B,C,D) example
[b,a] = ss2tf(A,B,C,D,ni) example
Description
[b,a] = ss2tf(A,B,C,D) converts a state-space representation of a system into an equivalent transfer example
function. ss2tf returns the Laplace-transform transfer function for continuous-time systems and the Z-transform
transfer function for discrete-time systems.
example
[b,a] = ss2tf(A,B,C,D,ni) returns the transfer function that results when the nith input of a system with
multiple inputs is excited by a unit impulse.
Mass-Spring System
A one-dimensional discrete-time oscillating system consists of a unit mass, , attached to a wall by a spring of unit elastic
constant. A sensor samples the acceleration, , of the mass at Hz.
Fs = 5;
dt = 1/Fs;
N = 50;
t = dt*(0:N-1);
where is the state vector, and are respectively the position and velocity of the mass, and the matrices
The system is excited with a unit impulse in the positive direction. Use the state-space model to compute the time evolution of the
system starting from an all-zero initial state.
u = [1 zeros(1,N-1)];
x = [0;0];
file:///F:/Application/mlab/help/matlab/ref/ss2tf.html 1/9
11/12/2018 ss2tf
for k = 1:N
y(k) = C*x + D*u(k);
x = A*x + B*u(k);
end
stem(t,y,'v','filled')
xlabel('t')
Compute the time-dependent acceleration using the transfer function H(z) to filter the input. Plot the result.
[b,a] = ss2tf(A,B,C,D);
yt = filter(b,a,u);
stem(t,yt,'d','filled')
xlabel('t')
file:///F:/Application/mlab/help/matlab/ref/ss2tf.html 2/9
11/12/2018 ss2tf
bf = [1 -(1+cos(dt)) cos(dt)];
af = [1 -2*cos(dt) 1];
yf = filter(bf,af,u);
stem(t,yf,'o','filled')
xlabel('t')
file:///F:/Application/mlab/help/matlab/ref/ss2tf.html 3/9
11/12/2018 ss2tf
Two-Body Oscillator
An ideal one-dimensional oscillating system consists of two unit masses, and , confined between two walls. Each mass is
attached to the nearest wall by a spring of unit elastic constant. Another such spring connects the two masses. Sensors sample
and , the accelerations of the masses, at Hz.
Fs = 16;
dt = 1/Fs;
N = 257;
t = dt*(0:N-1);
where is the state vector and and are respectively the location and the velocity of the -th
mass. The input vector and the output vector . The state-space matrices are
file:///F:/Application/mlab/help/matlab/ref/ss2tf.html 4/9
11/12/2018 ss2tf
ux = [1 zeros(1,N-1)];
u0 = zeros(1,N);
u = [ux;u0];
Use the model to compute the time evolution of the system starting from an all-zero initial state.
x = [0;0;0;0];
for k = 1:N
y(:,k) = C*x + D*u(:,k);
x = A*x + B*u(:,k);
end
stem(t,y','.')
xlabel('t')
legend('a_1','a_2')
title('Mass 1 Excited')
grid
file:///F:/Application/mlab/help/matlab/ref/ss2tf.html 5/9
11/12/2018 ss2tf
Convert the system to its transfer function representation. Find the response of the system to a positive unit impulse excitation on
the first mass.
[b1,a1] = ss2tf(A,B,C,D,1);
y1u1 = filter(b1(1,:),a1,ux);
y1u2 = filter(b1(2,:),a1,ux);
Plot the result. The transfer function gives the same response as the state-space model.
stem(t,[y1u1;y1u2]','.')
xlabel('t')
legend('a_1','a_2')
title('Mass 1 Excited')
grid
The system is reset to its initial configuration. Now the other mass, , receives a unit impulse in the positive direction. Compute
the time evolution of the system.
u = [u0;ux];
x = [0;0;0;0];
for k = 1:N
y(:,k) = C*x + D*u(:,k);
x = A*x + B*u(:,k);
end
Plot the accelerations. The responses of the individual masses are switched.
stem(t,y','.')
xlabel('t')
legend('a_1','a_2')
title('Mass 2 Excited')
grid
file:///F:/Application/mlab/help/matlab/ref/ss2tf.html 6/9
11/12/2018 ss2tf
Find the response of the system to a positive unit impulse excitation on the second mass.
[b2,a2] = ss2tf(A,B,C,D,2);
y2u1 = filter(b2(1,:),a2,ux);
y2u2 = filter(b2(2,:),a2,ux);
Plot the result. The transfer function gives the same response as the state-space model.
stem(t,[y2u1;y2u2]','.')
xlabel('t')
legend('a_1','a_2')
title('Mass 2 Excited')
grid
file:///F:/Application/mlab/help/matlab/ref/ss2tf.html 7/9
11/12/2018 ss2tf
A— State matrix
matrix
B— Input-to-state matrix
matrix
C— State-to-output matrix
matrix
D— Feedthrough matrix
matrix
ni — Input index
1 (default) | integer scalar
Transfer Function
See Also
latc2tf | sos2tf | ss2sos | ss2zp | tf2ss | zp2tf
file:///F:/Application/mlab/help/matlab/ref/ss2tf.html 8/9
11/12/2018 ss2tf
file:///F:/Application/mlab/help/matlab/ref/ss2tf.html 9/9