Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 5

%Pardeep KumarE072074

Experiment:
AIM: WAP to find DFT of the given sequence.
M-file editor:
clc;
N=input('length of
sequence');
x=input('Enter the
sequence : ');
display(x);
subplot(3,3,1);
stem(x);
ylabel('x[n]');
xlabel('[n]');
y=zeros(1,N);
for k = 0:1:(N-1)
for n=0:1:(N-1)
z=(j*2*pi*k*n)/N;
y(k+1) = x(n+1)*exp(z)
+y(k+1);
end
end
subplot(3,3,2);
stem(y);
Command Window:
length of sequence: 4
Enter the sequence : [2
3 4 5]
x=
2
3
4
5
>> ifft(y)
Ans :
2.0000 - 0.0000i
3.0000 0.0000i 4.0000
+ 0.0000i 5.0000 +
0.0000i

Output:

%Pardeep KumarE072074

EXPERIMENT NO-7
AIM: WAP FOR FINDING MAGNITUDE AND PHASE RESPONSE OF
THE SYSTEM
M-FILE EDITOR
close all;
clc;
num=[1 0 1];
den=[1 3 2];
t=0:1:2;
freqz(num,den,t)

Magnitude (dB)

-6
-8
-10
-12
-14

0.1

0.2
0.3
0.4
0.5
Normalized Frequency ( rad/sample)

0.6

0.1

0.2
0.3
0.4
0.5
Normalized Frequency ( rad/sample)

0.6

Phase (degrees)

100

-100

-200

%Pardeep KumarE072074

EXPERIMENT NO -

%WAP to find Cross-correlation function.


clc
clear all
v=input('Starting point of 1st Sequence =');
x=input('Enter second sequence i.e. x(N) = ');
a=length(x);
u=input('Starting point of 2nd Sequence =');
h=input('Enter second sequence i.e. h(n) =');
b=length(h);
g=[zeros(1,b-1) x];
i=h;
y=zeros(1, a+b-1);
e=a;
f=0;
for n=1:a+b-1
q=[zeros(1,f) i zeros(1,e-1)];
for k=1:a+b-1
y(1,n)=y(1,n)+g(1,k)*q(1,k);
end
e=e-1;
f=f+1;
end
fprintf('Range of the N for result')
p=v+u;
q=p+a+b-2;
size=p:q
'xCorrelation - OUTPUT Y: '
y=y
COMMAND WINDOW RESULT:
Starting point of 1st Sequence =2
Enter second sequence i.e. x(N) = [2 1 0 -2]
Starting point of 2nd Sequence =2
Enter second sequence i.e. h(n) =[2 1 0 -2]
Range of the N for result
size =
4
5
6
7
8
9 10
ans =
Correlation - OUTPUT Y:
y=
-4 -2
2
9
2 -2 -4
>> xcorr(x,h)

ans = -4.0000
-4.0000

-2.0000

2.0000

9.0000

% Pardeep KumarE072074

EXPERIMENT NOAIM: To develop program for computing inverse z-transform


M-FILE EDITOR
N=input('NUM> sequence to find z-transform, N');
D=input('DEN> sequence to find z-transform, D');
F=tf(N,D,1)
[r,p,k]=residuez(N,D)
h=impz(N,D,10)
COMMAND WINDOW:
NUM> sequence to find z-transform, N[1 2 0]
DEN> sequence to find z-transform, D[2 1 4 -1]
Transfer function:
z^2 + 2 z
--------------------2 z^3 + z^2 + 4 z - 1
Sampling time: 1
r = 0.1962 - 0.3044i
0.1962 + 0.3044i
0.1076
p = -0.3653 + 1.4265i
-0.3653 - 1.4265i
0.2306
k = []
h=
0.5000
0.7500
-1.3750
-0.5625
3.4063
-1.2656
-6.4609
7.4648
8.5566
-22.4385

2.0000

-2.0000

%Pardeep KumarE072074

EXPERIMENT NOAIM:To develop program for finding response of the LTI system described by
difference equation:
Y(n)+2Y(n)-3Y(n-2)=X(n)+2X(n-1)
M-FILE EDITOR
N=input('Numerator of H(z) : ')
D=input('Denomenator of H(z) : ')
disp('Impulse Response of H(z) : ')
H=impz(N,D,10)
stem(H)
title('Impulse Response of H(z)')
COMMAND WINDOW RESULT & FIGURE:
Numerator of H(z) : [1 2 0]
N= 1 2 0
Denomenator of H(z) : [1 2
-3]
D = 1 2 -3
Impulse Response of H(z) :
H=
1
0
3
-6
21
-60
183
-546
1641
-4920

You might also like