Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

1.(a) 1.

(b)

clc PI Controller
clear all ki=10;kp=10;
close all numI=[kp ki];
p=4 denI=[1 0];
q=[1 1 2] dr=conv(denI,den);
a=tf(p,q) display(‘Transfer function of PI controller with
r=[1 0] out FB’);
s=[1 2] sys2=tf(numI,dr)
b=tf(r,s) display(‘Transfer function of PI controller with
c=series(a,b) G2=feedback(sys2,1)
ans=feedback(c,1,-1) m=step(G2);
subplot(2,3,4);plot(m);
k=degain(G2)
time(‘PI control Kp=10 and Ki=10’)

PD Controller
Kd=10;
numc=[Kd Kd];
nr=conv(num,numc);
display(‘Transfer function for PD controller with out FB’);
sys1=tf(nr,den)
display(‘Transfer function for PD controller with FB’);
G1=feedback(sys1,1)
m=step(G1);
subplot(2,3,3);plot(m);
title(‘PD control Kp=10 and Kd=10’)
2.(a) 2.(b)

close all; clear all;


clear all; A=[0 1; -2 -3];
clc; B=[0; 1;];
sync s; C=[1 -1;];
P1=2/s; D=0;
P2=1/(s+1); mysys= ss (A,B,C,D);
L1=-1/s; q0=[1;2;];
L2=-2/s; initial(mysys,q0);
L3=-1/(s+1);
delta=1-(L1+L2+L3)+L1*L3;
delta a1=1;
delta a2=1-1;
TF=(P1*delta1+P2*delta2)/delta;
display(simplify (TF));

3.(a) 3.(b)

s=tf(‘s’); num=[0 0 1];


numerator=s^2+2*s+3; den=[1 0.8 1];
denominator=s^3+4*s^2+5*s+6; nyquist(num,den);
G=numerator/denominator; v=[-2 2 -2 2];
poles=pole(G); axis(v);
zeros=zero(G); grid(v);
disp(‘Poles of the transfer function:’); title(‘Nyquist Plot of G(s)=1/s^2+
disp(poles); 0.8+1)’)
disp(‘Zeros of the transfer function:’);
disp(zeros);
figure;
pzmap(G);
title(‘Pole-Zero Map’);
4.(a) 4.(b)

clc clear all;


clear all; n=[450];
close all; d=[1 12 20 0];
num=[8]; sys=tf(n,d);
den=[1 3 8]; bode(sys);
sys=tf(num,den) hold;
step (sys,0:0.01:10); margin(sys)
title(‘step response of system’);
[r,p,c]=residue(num,den)
Damping_ratio=den(2)/(2*sqrt(den(3)))

5.(a) clc 5.(b)


clear all; (i) clear all;
close all; n=[1];
num1=1; d=[1 1 0];
den1=[1 1.414 1]; sys=tf(n,d);
w=0:0.01:pi; zpk(sys);
h=freqs(num1,den1,w); rlocus(sys);
mag=abs(h); grid;
phase=angle(h);
figure (ii) clear all;
subplot(2,1,1) n=[1];
plot(w,mag) d=[1 3 2 0];
xlabel(‘Frequency’) sys=tf(n,d);
ylabel(‘Magnitude’) zpk(sys);
grid on rlocus(sys);
subplot(2,1,2) grid;
plot(w,phase) title(‘root locus of system with
xlabel(‘Frequency’) addition of poles’);
ylabel(‘Phase’)
title(‘Phase Spectrum of H1’)
grid on
6.(a)

T_lead=0.1;
T_lag=10;
num=[T_lead 1];
den=[T_lag 1];
compensator=tf(num,den);
w=logspace(-2,2,500);
[mag,phase,w]=bode(compensator,w);
magdB=20 * log10(mag);
phaseDeg=phase * (180/pi);
figure;
subplot(2,1,1);
semilogx(w,squeeze(magdB));
grid on;
title(‘Magnitude Response of Lead-Lag Compensator’);
xlabel(‘Frequency (rad/s)’);
ylabel(‘Magnitude(dB)’);
subplot(2,1,2);
semilogx(w,squeeze(phaseDeg));
grid on;
title(‘Phase Response of Lead-Lag Compensator’);
xlabel(‘Frequency (rad/s’);
ylabel(‘Phase (degrees)’);
6.(b)

coefficients=input(‘Enter the coefficients of the characterstic polynomial ‘);


n=lenghth(coefficients);
routh=zeros(n,ceil(n/2)*2);
routh(1:2:end, 1) = coefficients(1:2:end);
routh(2:2:end, 1) = coefficients(2:2:end);
for i = 3:n
for j = 1:ceil(n/2)*2-1
routh(i,j) = -1 / routh(i -1, 1) * det([routh(i -2, 1), routh(i -2,j + 1); routh
(i - 1, 1), routh(i -1 ,j + 1)]);
end
if mod(n, 2) == 0 && mod(i, 2) == 1
routh(i, end) = 0;
end
end
sign_changes = 0;
for i = 1:n – 1
if sign(routh(i, 1)) * sign(routh(i + 1, 1)) < 0
sign_changes = sign_changes + 1;
end
end
if sign_changes == 0
disp(‘System is stable’);
else sign_changes > 0
disp(System may be unstable’);
end

You might also like