Converting Transfer Function Models to State-Space Models Using MATLAB

First, write out the numerator and denominator expressions of the system’s transfer function model, then call tf2ss() to obtain the four matrices of the state-space model, and finally plot the system’s response curve to the input signal.

% Transfer function conversion to state-space %G(s)=num(s)/den(s); %X’=A*X+B*U; %Y=C*X+D*U; %[A,B,C,D]=tf2ss(num,den); %%%%%%%%%%%%%%%%%%%% clear all; clc; close all; %%%%%%%%%%%%%%%%%% num1=[1 2 3 ; 4 5 6]; %[s^2+2*s+3; 4*s^2+5*s+6]; den1=[7 8 9 10]; %[7*s^3+8*s^2+9*s+10]; [A,B,C,D]=tf2ss(num1,den1); disp(‘A:’); disp(‘B:’); disp(‘C:’); disp(‘D:’); disp(‘Transfer function:’); printsys(num1,den1); %%%%%%%%%%%%%%%%% t1=0:0.01:20; x1=3.0*sin(2*pi*4*t1); [y2,t2]=lsim(num1,den1,x1,t1); plot(t1,y2(:,1),’r’); hold on; plot(t1,y2(:,2),’b’); %% plot(t1,x1,’k’); title(‘Output Response’); xlabel(‘Time (s)’); ylabel(‘y’); legend(‘y1′,’y2’); hold off; disp(‘End.’);

Leave a Comment