0% found this document useful (0 votes)
3 views7 pages

State Space Conversion in MATLAB

The document contains MATLAB code for analyzing linear time-invariant systems using state-space representation and transfer functions. It includes calculations for zero input and zero state responses, Laplace transforms, and inverse Laplace transforms. Additionally, it discusses system stability and impulse response characteristics.

Uploaded by

Man T Luong
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views7 pages

State Space Conversion in MATLAB

The document contains MATLAB code for analyzing linear time-invariant systems using state-space representation and transfer functions. It includes calculations for zero input and zero state responses, Laplace transforms, and inverse Laplace transforms. Additionally, it discusses system stability and impulse response characteristics.

Uploaded by

Man T Luong
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

DEN=[1 3 8];

NUM=[0 1 5];
[A,B,C,D]=tf2ss(NUM,DEN);
X0=[0.5;1];
syms t;
yzi=C*expm(A*t)*X0;
DEN=[1 11 24];
NUM=[0 5 3];
[A,B,C,D]=tf2ss(NUM,DEN);
% Zero Input Response
X0=[1;1];
syms t;
yzi=C*expm(A*t)*X0
% Zero State Response;
G=tf(NUM,DEN);% you can define TF, but it will be in polynomial
syms s;
G_syms = poly2sym(NUM,s)/poly2sym(DEN,s);
X=laplace(exp(-t)*heaviside(t-2));
X_syms=poly2sym(X,s);
Yzs=G_syms*X_syms;
yzs=ilaplace(Yzs)
DEN=[1 0 9];
NUM=[0 1 0];
[A,B,C,D]=tf2ss(NUM,DEN);
% zero input response
X0=[1;1];
syms t;
yzi=C*expm(A*t)*X0
%zero state response
syms s;
G_syms=poly2sym(NUM,s)/poly2sym(DEN,s);
x=heaviside(t)-exp(-t)*heaviside(t);
X=laplace(x);
X_syms=poly2sym(X,s);
Yzs=G_syms*X_syms;
yzs=ilaplace(Yzs)
syms t;
f=(t^2)*exp(-3*t)*cos(4*t)*heaviside(t);
F=laplace(f)

syms s;
F=(s^2-4*s+4)/(s*(s+1)*(s+3));
f=ilaplace(F)

DEN=[1 10 31 30];
NUM=[0 0 1 1];
[A,B,C,D]=tf2ss(NUM,DEN);
syms t;
X0=[0.3;0.2;0.1];
yzi=C*expm(A*t)*X0

DEN=[1 6 5 0];
NUM=[0 1 17 20];
%zero state response
syms s;
syms t;
G_syms=poly2sym(NUM,s)/poly2sym(DEN,s);
x=exp(-2*t)*heaviside(t-1)+exp(-5*t)*heaviside(t-2);
X=laplace(x);
X_syms=poly2sym(X,s);
Yzs=G_syms*X_syms;
yzs=ilaplace(Yzs)
% Modify the code from Test2_Parctice_Problems_3.m and also Refer
% solutions
% Zero Input Response
syms z;
Yzi=(0.3-0.05*z^(-1))/(1-(0.5)*z^(-1)+(0.5)*z^(-2));
yzi=iztrans(Yzi);
% Zero State Response
X=z/(3*(z - 1/3)); % the z transform of the x[n];
DEN=[1 -0.5 -0.5];
NUM=[0 1 -0.5];
G_syms = poly2sym(NUM,z)/poly2sym(DEN,z);
Yzs= G_syms*X;
yzs=iztrans(Yzs);
% (a) Total Response
y=yzs+yzi ;
% (b) Find State space and the ouput equations
[Ad,Bd,Cd,Dd]=tf2ss(NUM,DEN);
% (c) Check for Asymptotic or marginal stability;
[EVEC,EVAL]=eig(Ad); % Note one of the absolute values of eigen values is at 1,
% The given system is marginally stable
% (b) check for BIBO stablity
% Find the impulse response
X=1;
H= G_syms*X;
h=iztrans(H); % Impulse response is NOT absolutely summable, hence NOT BIBO stable

You might also like