Assignment Format
Assignment Format
UE17EC251
Group Members:
1. JUTHIK BV (PES1201700452)
2.KUSHAL N (PES1201701567)
3.SANJESH AJ (PES1201700436)
Assignment No 1-
1.1.a)
%program to find the product of polynomials
%1.1 a.
x1='Enter polynomial-1:';
p1=input(x1);
x2='Enter polynomial-2:';
p2=input(x2);
p=conv(p1,p2)
1.1.b1)
%1.1.b1
%transfer function in cascade
num1='Enter the numerator of first transfer function:';
n1=input(num1);
den1='Enter the denominator of first transfer function:';
d1=input(den1);
num2='Enter the numerator of second transfer function:';
n2=input(num2);
den2='Enter the denominator of second transfer function:';
d2=input(den2);
gn=conv(n1,n2);
gd=conv(d1,d2);
g1s=tf(n1,d1)
g2s=tf(n2,d2)
g_series=tf(gn,gd)
1.1.b2)
%transfer function in parallel
num1='Enter the numerator of first transfer function:';
n1=input(num1);
den1='Enter the denominator of first transfer function:';
d1=input(den1);
num2='Enter the numerator of second transfer function:';
n2=input(num2);
den2='Enter the denominator of second transfer function:';
d2=input(den2);
g1=tf(n1,d1);
g2=tf(n2,d2);
g_parallel=g1+g2
1.1.b3)
g1n='Enter the numerator of polynomial-1:';
g1n1=input(g1n);
g1d='Enter the denominator of polynomial-1:';
g1d1=input(g1d);
g2n='Enter the numerator of polynomial-2:';
g2n2=input(g2n);
g2d2='Enter the denominator of polynomial-2:';
g2d2=input(g2d2);
g1s=tf(g1n1,g1d1)
g2s=tf(g2n2,g2d2)
g=feedback(g1s,g2s)
1.2.a&b)
clc;clear;
C=input('Enter the capacitance : ');
R=input('Enter the resistance : ');
L=input('Enter the inductance : ');
V=input('Enter the voltage amplitude : ');
den=[C*L R*C 1];
T=tf(1,den)
dff2Vc = [-R/L -1/(L*C) +1/(L*C)];
fprintf('The differential Equation is\n');
fprintf("Vc'' = %f Vc' + %f Vc + %f V\n",dff2Vc(1),dff2Vc(2),dff2Vc(3));
1.2.c)
Circuit Diagram:
Output:
Assignment No 2-
2.1)
%after reducing
syms s;
g1=tf([1],[1,10]);
g2=tf([1],[1,1]);
g3=tf([1 0 1],[1 4 4]);
g4=tf([1 1],[1 6]);
h1=tf([1 1],[1 2]);
h2=2;
h3=1;
h2 = h2/g4;
Ga = series(g3,g4);
Gb = (Ga)/(1-(Ga*h1));
Gc = series(g2,Gb);
Gd = feedback(Gc,h2);
Ge = series(g1,Gd);
Gtotal = feedback(g1,Ge)
pzmap(Gtotal);
2.2.a)
b1=[1];
a1=[1 10];
g1s=tf(b1,a1);
[A1,B1,C1,D1]=tf2ss(b1,a1);
x01=[5];
sys1=ss(A1,B1,C1,D1);
subplot(6,1,1);
initial(sys1,x01,2)
R1=expm(A1);
t1=0.2;
subplot(6,1,2);
y1_t=[C1.*exp(A1.*t1)].*x01;
plot(y1_t)
title('y1(t)');
b2=[3 10 1];
a2=[1 8 5];
g2s=tf(b2,a2)
[A2,B2,C2,D2]=tf2ss(b2,a2)
x02=[0;1]
sys2=ss(A2,B2,C2,D2);
subplot(6,1,3);
initial(sys2,x02,2)
R2=expm(A2)
t2=0.5;
subplot(6,1,4);
y2_t=[C2.*exp(A2.*t2)].*x02
plot(y2_t)
title('y2(t)');
b3=[1 14];
a3=[1 3 3 1];
g3s=tf(b3,a3)
[A3,B3,C3,D3]=tf2ss(b3,a3)
x03=[0;5;0];
sys3=ss(A3,B3,C3,D3);
subplot(6,1,5);
initial(sys3,x03,5)
R3=expm(A3)
t3=4;
subplot(6,1,6);
y3_t=[C3.*exp(A3.*t3)].*x03
plot(y3_t)
title('y3(t)');
2.2.b)
step(g1_s1)
S1 = stepinfo(g1_s1,'RiseTimeThreshold',[0.00 0.90]);
rt1 = S1.RiseTime
ss_values1 = dcgain(g1_s1)
3.1.b)
%for a=0.1
gb = tf([10],[1 a1b 10]);
step(gb)
Sb = stepinfo(gb) %to get rise time ,settling time,overshoot,peakvalue etc
%change a values
3.1.c)
p1=5
%for p=5
gc =tf([10],[1 2 10])*tf([p1],[1 p1]); %becoz the two transfer func are
% in cascade
step(gc)
SC = stepinfo(gc)
%change p values
3.1.d)
a1=0.1;
%for a=0.1
g1 = tf([10],[1 2 10])*tf([1 a1],[a1]);
step(g1)
S1 = stepinfo(g1)
3.2)
g1 = tf([10],[1 2 10]);
subplot(4,1,1)
step(g1)
%a=tf([1],[1 0]);
a=tf('s');
subplot(4,1,2)
step(g1/a)
subplot(4,1,3)
step(g2)
%a=tf([1],[1 0]);
a=tf('s');
subplot(4,1,4)
step(g2/a)
Assignment No 4-
PART A
4.1.a)
%All responses are unbounded so stepinfo returns infinite values
%This avoided by changing code as in line 13 and 14
%p =1
num1 = [1];
den1 = [1 1 0];
sys1 = tf(num1,den1)
t1 = [0:4];
t2 = [5:8];
t3 = [t1 t2]
t = [0 8];
dt = [2*ones(size((t1))) 3*ones(size((t2)))];
a = step(sys1,t);
stepinfo(a)
subplot(3,3,1)
lsim(sys1,dt,t3)
%p=2
num2 = [1];
den2 = [1 2 0];
sys2 = tf(num2,den2)
b = step(sys2,t);
stepinfo(b) %to avoid issue of getting nAn
subplot(3,3,2)
lsim(sys2,dt,t3)
%p=5
num3 = [1];
den3 = [1 5 0];
sys3 = tf(num3,den3)
c = step(sys3,t);
stepinfo(c)
subplot(3,3,3)
lsim(sys3,dt,t3)
subplot(3,3,4)
impulse(sys1,sys2,sys3)
subplot(3,3,5)
step(sys1,sys2,sys3)
4.1.b)
%k = 20 when D(s) = 0 and only R(s) input.
num1 = [11 20];
den1 = [1 12 20];
sys1 = tf(num1,den1)
stepinfo(sys1)
subplot(4,3,1)
impulse(sys1,sys2,sys3)
subplot(4,3,2)
step(sys1,sys2,sys3)
%k=100
num4 = [11 100];
den4 = [1 12 100];
sys4 = tf(num4,den4)
stepinfo(sys4)
subplot(4,3,4)
impulse(sys4,sys5,sys6)
subplot(4,3,5)
step(sys4,sys5,sys6)
4.2)
%Automatic electric carrier
num = [10];
den = [1 12 30 100];
sys = tf(num,den)
subplot(3,3,4)
pzmap(sys) %pole zero map
subplot(3,3,1)
step(sys)
subplot(3,3,2)
impulse(sys)
a = step(sys);
stepinfo(a)
t = [0:0.1:8];
subplot(3,3,3)
lsim(sys,t,t) %ramp response
Inference-
All poles lie on left half of s-plane and three zeros located at infinity.
System is stable for both the step and impulse response.
Assignment No 5-
PART A
5.1)
%B
h=tf([1],[1 2 4 0])
k=1
th=feedback(h*k,1)
subplot(3,4,5)
step(th)
title('subplot 5:step tf2 for k=1')
h1=tf([1],[1 2 4 0])
k1=4
th1=feedback(h1*k1,1)
subplot(3,4,6)
step(th1)
title('subplot 6:step tf2 for k=4')
h2=tf([1],[1 2 4 0])
k2=8
th2=feedback(h2*k2,1)
subplot(3,4,7)
step(th2)
title('subplot 7:step tf2 for k=8')
%For gain K=8 the system is marginally stable K=1,2 stable.
subplot(3,4,8)
pzmap(h)
grid on
%pole at -1+root(3)i,-1-root(3),0
5.2)
syms s
res= [0 0]
for i= -2:2
for j= -2:2
trans=tf([i i*j],[1 8 17 (10+i) (i*j)]);
trans_s=tf([i i*j 0],[1 8 17 (10+i) (i*j)]);
if isstable(trans)==1
trans=(i*(s+j))/((s^4)+(8*(s^3))+(17*(s^2))+(s*(10+i))+(i*j));
trans_s=(i*s*(s+j))/((s^4)+(8*(s^3))+(17*(s^2))+(s*(10+i))+(i*j));
res=[res ;[i j]];
ramp=1/limit(trans_s,s,0)
unit=1/(1+limit(trans,s,0))
end
end
end
disp(res)
PART B
5.3)
[A,B,C,D]=tf2ss([10],[1 12 30 100])
%A=CONTROLLABLE CANONICAL FORM(Square matrice) B=(column matrix) C=row matrice D=0 .which
means output
%doesnt depend on the input
5.4)
clc;
clear;
k=-15:15
sys = tf(zeros(1,1,1,length(k)));
for j = 1:length(k)
sys(1,1,1,j) = tf([10*k(j)],[1 12 30 100+10*k(j)]); %[10],[1 12 30 100]
end
sys.SamplingGrid = struct('k',k);
B_elem = isstable(sys,'elem')
Inference-
System is stable for k > -10
Assignment No 6-
PART A
6.1)
GH = feedback(K*G,1) ;
subplot(2,1,2)
step(GH);
%K < 12 to meet design specifications
PART B
6.3.a)
K1 = 1 ; %stable
num = [10]
den = [1 12 30 100]
G = tf(num,den);
GH1 = feedback(K1*G,1) ;
figure
step(GH1) ;
title('K = 1') ;
stepinfo(GH1)
K2 = 10 ; %stable
GH2 = feedback(K2*G,1) ;
figure
step(GH2) ;
title('K = 10') ;
stepinfo(GH2)
K3 = 500 ; %unstable
GH3 = feedback(K3*G,1,-1) ;
figure
step(GH3) ;
title('K = 500') ;
stepinfo(GH3)
K4 = 200 ; %unstable
GH4 = feedback(K4*G,1,-1) ;
figure ;
step(GH4) ;
title('K = 200') ;
stepinfo(GH4)
Inference-
For higher values of k system becomes unstable.
6.3.b)
clear all ;
close all ;
clc ;
K = 5
num = [10]
den = [1 12 30 100]
G = tf(num,den);
GH = feedback(K*G,1) ;
figure
rlocus(G) ;
figure
step(GH) ;
Inference-
For K=5, the system is stable and the root locus is plotted for it.There is j omega
crossing and all poles lie on left half of s plane
Assignment No 7-
PART A
7.1)
G = tf([1],[1 11 10]);
subplot(3,4,1);
bode(G)
%{
bandwidth of CLTF is a finite number as the DC Gain is finite
whereas in the case of OLTF the DC gain is infinite. This shows that
negative feedback reduces the gain giving us a finite bandwidth range
%}
w = logspace (-1,3)
bode (G1closedloop,w)
%from graph obtained we estimate wn= 11 rad/s and damping ratio zeta= 0.297
wn= 11
zeta= 0.297
%{
(iv) From the closed loop transfer function, compute the actual damping
ratio and natural frequency and compare with the result obtained and
compare with the result obtained in part (iii)
%natural frequency wn and damping ratio zeta-
%}
[Wn,zeta] = damp(G1closedloop)
%{
We observe that comparitively the estimated values of Wn and zeta
from bode plot is very much similar to the calculated values.
%}
7.3)
K = 2;
g= tf([K],[1 21 20 K]);
%1 21 20 K
w = logspace(-1,3);
%Using the function 'bode'
bode(g,w)
grid on
[Wn,zeta] = damp(g)
PART B
7.4)
G = tf([10],[1 12 30 100])
%{
K = [2 -1];
zer = [5 0 -2];
%}
%K = 2, zero = 5
zero1=tf([1 -5],[1])
sys1=feedback(G*zero1*2,1)
subplot(4,4,1);
step(sys1);
stepinfo(sys1);
subplot(4,4,2);
rlocus(sys1);
title('k=2 and z=5')
%K = 2, zero = 0
zero2=tf([1 0],[1])
sys2=feedback(G*zero2*2,1)
subplot(4,4,3);
step(sys2);
stepinfo(sys2);
subplot(4,4,4);
rlocus(sys2);
title('k=2 and z=0')
%K = 2, zero = -2
zero3=tf([1 2],[1])
sys3=feedback(G*zero3*2,1)
subplot(4,4,5);
step(sys3);
stepinfo(sys3);
subplot(4,4,6);
rlocus(sys3);
title('k=2 and z=-2')
figure
%
%K = -1, zero = 5
zero4=tf([1 -5],[1])
sys4=feedback(G*zero4*-1,1)
subplot(4,4,7);
step(sys4);
stepinfo(sys4);
subplot(4,4,8);
rlocus(sys4);
title('k=-1 and z=5')
%K = -1, zero = 0
zero5=tf([1 0],[1])
sys5=feedback(G*zero5*-1,1)
subplot(4,4,9);
step(sys5);
stepinfo(sys5);
subplot(4,4,10);
rlocus(sys5);
title('k=-1 and z=0')
%K = -1, zero = -2
zero6=tf([1 2],[1])
sys6=feedback(G*zero6*-1,1)
subplot(4,4,11);
step(sys6);
stepinfo(sys6);
subplot(4,4,12);
rlocus(sys6);
title('k=-1 and z=-2')
figure
%K = 2
syst1 = feedback(G*2,1);
subplot(4,4,13);
step(syst1);
stepinfo(syst1);
subplot(4,4,14);
rlocus(syst1);
title('k=2')
%K = -1
syst2 = feedback(G*(-1),1);
subplot(4,4,15);
step(syst2);
stepinfo(syst2);
subplot(4,4,16);
rlocus(syst2);
title('k=-1')
Assignment No 8-
8.1)
num=[10]
den=[3/200 151/100 1]
H=1
G=tf(num,den)
T=feedback(G,H)
nyquistplot(T)
num=[20]
den=[1/125 6/25 1 0]
H=1
G=tf(num,den)
T=feedback(G,H)
nyquistplot(T)
num=[0.5 1]
den=[0.33 1 0 0 ]
G=tf(num,den)
H=1
T=feedback(G,H)
nyquistplot(T)
8.2)