You are on page 1of 11

1

-K- -K-
s
Step Gain Integrator Gain1 Scope

t
Clock
To Workspace

% unit impulse signal


clc; clear all;
t = -2:1:2;
y = [zeros(1,2),ones(1,1),zeros(1,2)];
subplot(2, 2, 1) ;
stem(t,y);
ylabel('amplitude');
xlabel('n');
%unit step sequence
n = input('Enter the length of sequence N = ');
t = 0:1:n-1;
y1 = ones(1,n);
subplot(2, 2, 2);
stem(t,y1);
ylabel('amplitude');
% Ramp sequence
n1 = input('Enter length of ramp =');
t = 0:n1;
subplot(2, 2, 3 );
stem( t,t);
ylabel('Amplitude');
%Exponential sequence
n2 = input('Enter length of exponential sequence =');
t = 0:n2;
a = input('enter the value of a = ');
y2= exp(a*t);
subplot(2,2,4);
stem(t,y2);
ylabel('amplitude');

Enter the length of sequence N = 8

Enter length of ramp =8

Enter length of exponential sequence =7

enter the value of a = 1

1 1
amplitude

amplitude

0.5 0.5

0 0
-2 -1 0 1 2 0 2 4 6 8
n

8 1500

6
1000
Amplitude

amplitude

4
500
2

0 0
0 2 4 6 8 0 2 4 6 8

clear all;
clc;
for k=1:1:2000
den=[ 1 6 11 6+k];
poles=roots(den);
r=real(poles);
if max(r) >=0
poles
k
break
end
end

poles =

-6.0212

0.0106 + 3.3358i

0.0106 - 3.3358i

k=

61

clc;
num=[0 0 0 100];
den=[1 12 20 0];
rlocus(num,den)
title('root locus of the transfer function G(s)H(s)=100k/s(s+2)(s+10)')
[k,p]=rlocfind(num,den)
G=tf(num,den);
root locus of the transfer function G(s)H(s)=100k/s(s+2)(s+10)
30
0.76 0.64 0.5 0.34 0.16

0.86
20

0.94

10
0.985
Imaginary Axis

40 35 30 25 20 15 10 5
0

0.985
-10

0.94

-20
0.86

0.76 0.64 0.5 0.34 0.16


-30
-40 -30 -20 -10 0 10 20
Real Axis

clc;
num=[0 0 0 100];
den=[1 4 3 0];
rlocus(num,den)
title('root locus of the transfer function G(s)H(s)=100k/s(s+1)(s+3)')
[k,p]=rlocfind(num,den)
T=tf(num,den);
root locus of the transfer function G(s)H(s)=100k/s(s+1)(s+3)
10
0.68 0.56 0.42 0.28 0.14
0.8
8

6
0.91
4
0.975
2
Imaginary Axis

12 10 8 6 4 2
0

-2
0.975
-4
0.91
-6

-8
0.8
0.68 0.56 0.42 0.28 0.14
-10
-12 -10 -8 -6 -4 -2 0 2 4
Real Axis

clc;
clear all;
num=[25];
den=[1 17 60 0];
sys=tf(num,den);
sys
bode(sys)
Grid on ;
[gm pm wgm wpm]=margin(sys);
gm
pm
wgm
wpm
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
Transfer function:

25

-------------------

s^3 + 17 s^2 + 60 s

gm =

40.8000

pm =

83.2759

wgm =

7.7460

wpm =

0.4149

Gm_dB =
32.2132

The stability :stable

Bode Diagram
50

0
Magnitude (dB)

-50

-100

-150
-90

-135
Phase (deg)

-180

-225

-270
-1 0 1 2 3
10 10 10 10 10
Frequency (rad/sec)
gm =
2.8000

pm =

29.0851

wgm =

3.1623

wpm =

1.7667

Gm_dB =

8.9432

The stability :stable

clc;
clear all;
syms z n
ztrans(1/4^n)

ans =

z/(z - 1/4)

clc;
close all;
clear all;
syms z n
iztrans(2*z/(2*z-1))

ans =

(1/2)^n
Bode Diagram
100

50
Magnitude (dB)

-50

-100

-150
-90

-135
Phase (deg)

-180

-225

-270
-2 -1 0 1 2 3
10 10 10 10 10 10
Frequency (rad/sec)