Control Systems MATLAB File
Control Systems MATLAB File
Agam Singh
03913204914
EEE
(2015-2016)
EXPERIMENT -5
ADVANTAGES OF MATLAB:
1. A very large database of built-in algorithms for image processing
and computer vision applications
2. MATLAB allows you to test algorithms immediately without
recompilation. You can type something at the command line or
execute a section in the editor and immediately see the results,
greatly facilitating algorithm development.
3. The MATLAB Desktop environment, which allows you to work
interactively with your data, helps you to keep track of files and
variables, and simplifies common programming/debugging tasks
4. The ability to read in a wide variety of both common and domainspecific image formats.
5. Clearly written documentation with many examples, as well as
online resources such as web seminars ("webinars").
DISADVANTAGES OF MATLAB:
1. Requires excellent programming skills
2. Takes long time to develop and test
3. The debugging process takes time as the source code is interpreted
rather than compilation
4. The program is usually written for a dedicated simulation problem
5. It is necessary to get the mathematical model of simulated system
and this may be difficult to handle.
6. The source code is not available and hence it is not possible to
modify/upgrade the simulation package.
EXPERIMENT-2
AIM:
(a)Given a transfer function, compute its representation in zero
and pole form along with its pole zero plot.
(b)Also a system being represented by its zeroes, poles and
gain k, find its transfer function.
clc;
close all;
clear all;
% PART A
n = [1];
d = [1 2 8 3 16];
g = tf(n,d)
[z,p,k] = tf2zp(n,d)
pzmap(g)
%PART B
fprintf('PART B:-')
z = [-3;-1]
p = [0;-1;-2;-3]
k=7
[num,den] = zp2tf(z,p,k)
g=tf(num,den)
OUTPUT:
PART A:-
PART B:-
EXPERIMENT 3
AIM:
clc;
clear all;
close all;
n1 = [11];
d1 =[1 5 6];
g1 = tf(n1,d1)
n2 = [7];
d2 = [1 9];
g2 = tf(n2,d2)
fprintf(' Connected in cascade')
g3 = series(g1,g2)
fprintf(' connected in parallel')
g4 = parallel(g1,g2)
fprintf(' conected in feedback')
g5 = feedback(g1,g2)
EXPERIMENT-4
AIM:
Consider the following system defined by its transfer function
G(S)=16/(s^2+4s+16).
a)Obtain the unit step response curve using MATLAB.
b)Obtain the unit impulse reponse.
c)Obtain its unit ramp response.
d)What will be the time response for an arbitrary input r=t+2.
% expt 4(a)
% to plot unit step response
clc;
clear all;
close all;
num=[16];
den=[1 4 16];
g=tf(num,den)
step(g)
stepinfo(g)
grid on;
title('Step response plot for G(s) is:');
% expt 4(b)
% to plot impulse response
clc;
clear all;
close all;
num=[16];
den=[1 4 16];
g=tf(num,den)
impulse(g)
grid on;
title('Impulse response plotfor G(s) is:');
% expt 4(c)
% to plot ramp response
clc;
clear all;
close all;
num=[16];
den=[1 4 16];
sys=tf(num,den);
disp('The given response is:')
t=0:1:10
r=step(num,den,t);
plot(t,r,'*',t,t,'o');
grid on;
title('Unit ramp response is:');
xlabel('Time(sec)--------->');
ylabel('reference input curve and output curve');
% expt 4(d)
% to plot response for input r=t+2
clc;
clear all;
close all;
num=[16];
den=[1 4 16];
sys=tf(num,den)
disp('The given response is:')
t=0:0.1:10
r=2+t;
c=lsim(num,den,r,t);
plot(t,r,'*',t,c,'o');
grid on;
title('Response for specified input r=t+2 is:');
xlabel('Time(sec)--------->');
ylabel('Output c(t) and given input r(t)');
EXPERIMENT-5
AIM:
Consider the negative unity feedback control system with the
following feed forward transfer function g(S)=k/s(s^2+9s+20). Plot
the root loci in MATLAB. Find the closed loop poles that have the
damping ratio of 0.2. find the values of gain k at this point.
clc;
clear all;
close all;
% let k=1
num=[1];
den=[1 9 20 0];
rlocus(num,den)
title('Root locus plot');
xlabel('Real axis');
ylabel('imaginary axis');
sgrid(0.2,[])
[k,r]= rlocfind(num,den)
disp('Select a point in the Graphics window');
EXPERIMENT-6
AIM:
Find the number of roots in the right half plane of s-plane for
f(S)=s^4+6s^3+11s^2+11s+6 using MATLAB and thereby check the
system stability.
clc;
clear all;
close all;
poly=[1 6 11 11 6]
disp('The routh array formulated is')
dim=size(poly)
coe=dim(2)
rsc=sym(zeros(coe,ceil(coe/2)));
for i=1:coe
rsc(2-rem(i,2),ceil(i/2))= poly(i);
end
for i=3:coe
for j=1:2
rsc(i,j)= -det([rsc(i-2,1) rsc(i-2,j+1);
rsc(i-1,1) rsc(i-1,j+1)])/rsc(i-1,1)
end
end
EXPERIMENT-7
AIM:
Consider a system defined by G(S)=1/(s(0.7s+1)(s+1).Obtain the
bode frequency diagram.Obtain the resonant peak,resonant
frequency and bandwidth.
clc;
clear all;
close all;
num=[1];
den= conv([1,0], conv([0.7 1],[1 1]));
g=tf(num,den)
w1=logspace(-1,1);
bode(g,w1)
[magnitude,phase,w]=bode(g,w1);
[rp,k]=max(magnitude);
disp('Reasonant Peak');
RP= 20*log10(rp)
disp('Resonant Frequency');
RF=w(k)
bw=1;
while 20*log(magnitude(bw))>=-3;
bw=bw+1;
end
disp('Bandwidth');
BW=w(bw)
EXPERIMENT-8
AIM:
For the given transfer function G(S)=1/(s^2+2s+3); Draw the nyquist
plot using MATLAB functions.
clc;
clear all;
close all;
num=[1];
den=[1 2 3];
G=tf(num,den)
nyquist(G)
grid on;
title('The Nyquist plotfor G(s)=1/s^2+2s+3');
EXPERIMENT 9
AIM:
To study the time and frequency response of common RLC circuit.