EXPERIMENT Programs
EXPERIMENT Programs
a) a = 5; x = 2; y = 8;
y = exp(-a)*sin(x)+10*sqrt(y)
Ans :28.2904
b)
x = 0:0.01:2*pi
y1 = 2*cos(x)
y2 = cos(x)
y3 = 0.5*cos(x)
plot(x,y1,"--",x,y2,"-",x,y3,":")
xlabel("x ")
ylabel("Cosine functions")
legend("2*cos(x)", "cos(x)", "0.5*cos(x)")
c) a = 0:0.5:5;
b = 2*a.^2 + 3*a -5;
c = 1.2*a.^2+4*a-3;
subplot(1,2,1)
plot(a,b,"-or","MarkerFaceColor","g","LineWidth",2)
xlabel('X'); ylabel('Y'); legend('Curve ','Location','NorthWest')
subplot(1,2,2)
plot(a,c,"-ok","MarkerFaceColor","g","LineWidth",2)
xlabel('X'); ylabel('Y'); legend('Curve 2','Location','NorthWest')
EXPERIMENT 2
clc;
clear;
t=-2:1:2;
y=[zeros(1,2),ones(1,1),zeros(1,2)];
subplot(2,2,1);
plot(t,y,'b+');
stem(t,y);
xlabel('time');
ylabel('magnitude');
legend('IMPULSE');
y1=[zeros(1,2),ones(1,3)];
subplot(2,2,2);
plot(t,y1,'r+');
stem(t,y1);
xlabel('time');
ylabel('magnitude');
legend('STEP');
%RAMP
t=0:1:5
subplot(2,2,3)
plot(t,t);
stem(t,t);
xlabel('time');
ylabel('magnitude');
legend('RAMP');
%Parabolic signal
t=0:1:5
a=5;
y2=[power(t,2)\2];
subplot(2,2,4);
plot(t,y2);
stem(t,y2);
xlabel('time');
ylabel('magnitude');
legend('PARABOLIC');
EXPERIMENT 3
clear all
clc
n=[5 15 10];
d=[2 7 20 24 0];
G=tf(n,d)
pzmap(G)
EXPERIMENT 4
s = tf('s');
R = 10000;
C = 100*10^-6;
G = 1/(C*R*s+1);
subplot(3,1,1)
step (G)
subplot(3,1,2)
impulse(G)
% Ramp Function
t = -1:0.1:1;
x1= t>0;
u = (t.*x1);
subplot(3,1,3)
plot(lsim(G,u,t));
EXPERIMENT 5
clc;
clear all;
close all;
num = [1];
den = [1 1 4];
g = tf(num,den)
t = feedback(g,1)
impulse(t)
step(t)
subplot(2,1,1),plot(impulse(t));
legend ('impulse response')
subplot(2,1,2)
plot(step(t));
legend ('step response')
EXP 6 Rootlocus
num=[1];
den=[1 8 17 0];
figure(1);
sys=tf(num,den)
rlocus(sys)
transfer function
G(s)=1/(S^3+8S^2+17S)')
grid;
EXP 7 Bodeplot
clear all;
num=1
den=[0.5 1.5 1 0];
y=tf(num,den);
bode(y)
grid on ;
[gm pm wpm wgm]=margin(y)
Gm_dB = 20*log10(gm)
if(pm>gm)
disp(['The stability :stable',]);
else
if(pm<gm)
disp(['The stability :unstable',]);
else
disp(['The stability :marginal stable',]);
end
end
EXP 8 Performance Analysis of Compensated
system
num1=[0 0 18.7 54.23];
den1=[1 7.4 29.5 54.23];
num=[0 0 4];
den=[1 2 4];
t=0:0.05:5;
sys=tf(num1,den1)
Y=tf(num,den)
step(sys,Y)
grid
title('unit step response of compensated and uncompensated system')
xlabel('t sec')
ylabel('Outputs C1 and C2)')
legend("compensated system", "uncompensated system")