'Enter The Sequence': Program
'Enter The Sequence': Program
DECIMATION IN TIME
%DIT%
clc;
r=input('Enter the sequence');
l=bitrevorder(r);
n=length(l);
m=log2(n);
for x=1:m;
p=2^x;
for y=1:p:n;
for z=1:(p/2);
k=exp(-i*2*pi*(z-1)/p);
a=l(y+z-1);
b=l(y+z+(p/2)-1);
c=a+b*k;
d=a-b*k;
l(y+z-1)=c;
l(y+z+(p/2)-1)=d;
disp(c);
disp(d);
end
end
end
disp('Result: ');
disp(l);
h=1:n;
subplot(2,1,1);
stem(h,abs(l));
xlabel('k');
ylabel('<x(k)');
title('Amplitude response');
subplot(2,1,2);
stem(h,angle(l));
xlabel('k');
ylabel('<x(k)');
title('Phase response');
RESULT
INPUT
[1 2 3 4 4 3 2 1]
OUTPUT
DECIMATION IN FREQUENCY
%DIF%
clc;
l=input('Enter the sequence');
n=length(l);
m=log2(n);
for x=1:m;
p=2^x;
for y=1:p:n;
for z=1:(p/2);
k=exp(-i*2*pi*(z-1)/p);
a=l(y+z-1);
b=l(y+z+(p/2)-1);
c=(a+b);
d=(a-b)*k;
l(y+z-1)=c;
l(y+z+(p/2)-1)=d;
disp(c);
disp(d);
end
end
end
disp('Result: ');
r=bitrevorder(l);
disp(r);
h=1:n;
subplot(2,1,1);
stem(h,abs(r));
xlabel('k');
ylabel('<x(k)');
title('Amplitude plot');
subplot(2,1,2);
stem(h,angle(r));
xlabel('k');
ylabel('<x(k)');
title('Phase angle plot');
RESULT
INPUT
[1 2 3 4 4 3 2 1]
OUTPUT
[20.0000 + 0.0000i -5.8284 - 2.4142i 0.0000 + 0.0000i
OUTPUT
Amplitude response
20
Amplitude response
20
15
15
<x(k)<x(k)
10
10
5
5
0
1 2 3 4 5 6 7 8
0 k
1 2 3 4 5 6 7 8
k
Phase response
3
Phase response
3
2
2
1
1
<x(k)<x(k)
0
0
-1
-1
-2
-2
-3
1 2 3 4 5 6 7 8
-3 k
1 2 3 4 5 6 7 8
k
IDFT
clc;
r=input('Enter the sequence:');
l=bitrevorder(r);
n=length(l);
m=log2(n);
for x=1:m
p=2^x;
for y=1:p:n
for z=1:(p/2);
k=exp(-i*2*pi*(z-1)/p);
t=conj(k);
a=l(y+z-1);
b=l(y+z+(p/2)-1);
c=a+(b*t);
d=a-(b*t);
l(y+z-1)=c;
l(y+z+(p/2)-1)=d;
disp(c);
disp(d);
end;
end;
end;
s=l/n;
disp(s);
RESULT
INPUT
[20.0000 + 0.0000i -5.8284 - 2.4142i 0.0000 + 0.0000i -0.1716 - 0.4142i 0.0000 + 0.0000i -0.1716 +
0.4142i 0.0000 + 0.0000i -5.8284 + 2.4142i]
OUTPUT
[ 1.0000 + 0.0000i 2.0000 + 0.0000i 3.0000 - 0.0000i 4.0000 - 0.0000i 4.0000 + 0.0000i 3.0000 - 0.0000i
2.0000 + 0.0000i 1.0000 + 0.0000i]
DFT FUNCTION
function [l]=confour(r)
l=bitrevorder(r);
n=length(l);
m=log2(n);
for x=1:m;
p=2^x;
for y=1:p:n;
for z=1:(p/2);
k=exp(-i*2*pi*(z-1)/p);
a=l(y+z-1);
b=l(y+z+(p/2)-1);
c=a+b*k;
d=a-b*k;
l(y+z-1)=c;
l(y+z+(p/2)-1)=d;
disp(c);
disp(d);
end
end
end
IDFT FUNCTION
function[g]=convolufive(r)
l=bitrevorder(r);
n=length(l);
m=log2(n);
for x=1:m;
p=2^x;
for y=1:p:n;
for z=1:(p/2);
k=exp(-i*2*pi*(z-1)/p);
t=conj(k);
a=l(y+z-1);
b=l(y+z+(p/2)-1);
c=a+(b*t);
d=a-b*t;
l(y+z-1)=c;
l(y+z+(p/2)-1)=d;
disp(c);
disp(d);
end
end
end
g=l/n;
CONVOLUTION
clc;
r1=input('enter the x1(n) ')
r2=input('enter the x2(n) ')
l1=confour(r1);
l2=confour(r2);
y=l1.*l2;
g=convolufive(y);
disp(g);
INPUT
xn=[1 2 3 0]
hn=[-1 1 0 0]
OUTPUT