0% found this document useful (0 votes)
43 views6 pages

Lab 8 - 084

This document contains 7 examples demonstrating the use of MATLAB functions for modeling and analyzing control systems. The examples cover converting ordinary differential equations to state space form, transferring between transfer function and state space models, modeling systems in cascade and feedback configurations, computing step responses, and reducing higher order systems.

Uploaded by

Ashar Asif
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)
43 views6 pages

Lab 8 - 084

This document contains 7 examples demonstrating the use of MATLAB functions for modeling and analyzing control systems. The examples cover converting ordinary differential equations to state space form, transferring between transfer function and state space models, modeling systems in cascade and feedback configurations, computing step responses, and reducing higher order systems.

Uploaded by

Ashar Asif
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
You are on page 1/ 6

Ashar Asif Lab#08 17B-084-EE

Example # 1:
Ode2phv Matlab function
function [A, B, C]=ode2phv(ai, k)
% This function converts an nth order ordinary differential equation:
% a(n) dAnx/dtAn + a(n-1) dA(n-1)x/dtA(n-1) + . . + a(1)dx/dt + a(0)x = k
% to the state-space phase variable form.
n=length(ai)-1;
I =eye(n-1);
z=zeros(n-1,1);
zi=[z,I];
for m=1:n
an(m)=-ai(n+2-m)/ai(1);
end
A=[zi;an];
B=[z;k/ai(1)];
C=[1 z'];

Matlab code
ai = [2 4 6 8];
k = 10;
[A, B, C] = ode2phv(ai,k)
Ashar Asif Lab#08 17B-084-EE

Example # 2:

num = [1 7 2];
den = [1 9 26 24];
[A, B, C, D] = tf2ss(num,den)

Example # 3 :

A = [0 1 0; 0 0 1; -1 -2 -3];
B = [10; 0; 0];
C = [1 0 0];
D = [0];
[num, den] = ss2tf(A,B,C,D,1);
G = tf(num,den)
Ashar Asif Lab#08 17B-084-EE

Example # 4 :
Gc = tf(5*[1 1.4],[1 7]); % transfer function Gc
Gp = tf([1],[1 5 4 0]); % transfer function Gp
H = 10;
G = series(Gc,Gp) % connect Gc and Gp in cascade
T = feedback(G,H) % close feedback loop
[num, den] = tfdata(T,'v') % return num and den as row vectors
[A, B, C, D] = tf2ss(num,den) % converts to state space model

Example # 5 :-

num = 25*[0.4 1];


den = conv([0.16 1], [1 6 25]) % Multiplies two polynomials.
T = tf(num,den) % Create TF object.
step(T), grid % Produces step response plot.
damp(T) % Produces data below: Eigenvalue Damping Freq. (rad/s)
Ashar Asif Lab#08 17B-084-EE

Example # 6 :-

num1= 750;
den1 = [1 36 205 750];
T = tf(num1,den1);% Third-order system tf object.
num2 = 25;
Ashar Asif Lab#08 17B-084-EE

den2 = [1 6 25];
Ttilde = tf(num2,den2);% Reduced system tf object.
[y1 t] = step(T); % Response and time vectors of T.
y2 = step(Ttilde,t); % Response using the same time
% vector of the reduced system.
plot(t,y1,'r-',t,y2,'b:') % Put responses on the same plot.
grid;
xlabel('Time (s)');
ylabel('Displacement');
legend('Third-order','Reduced-order');

Example # 7 :-

Gc = tf([50 70],[1 7]); % Transfer function Gc.


Gp = tf([1],conv([1 1 0],[1 4])); % Transfer function Gp, % with expanded denominator.
H = 1; % Unity feedback.
G = series(Gc,Gp); % Connect Gc and Gp in cascade.
T = feedback(G,H) % Close unity feedback loop.
Ashar Asif Lab#08 17B-084-EE

ltiview('step',T)

You might also like