Sunteți pe pagina 1din 8

%DIT IFFT

clc;
clear all;
close all;
n=input('enter no of points');
x0=input('enter array in bit reversal order');
x1=0;
x2=0;
m=log2(n);
for i1=1:m
p=n/(2^i1);
q=n/p;
for j1=1:q:n;
r=j1;
for k=1:(q/2)
a=x0(r);
b=x0(r+(q/2));
k1=cos(2*pi*(k-1)/q)+i*sin(2*pi*(k-1)/q);
c=a+k1*b;
d=a-k1*b;
x1(r)=c;
x1(r+(q/2))=d;
r=r+1;
end;
end;
x0=x1;
x2=x1;
x1=0;
end;
disp('output is');
x2=x2/n;
disp(x2);
n=0:1:n-1;
amp=abs(x2);
phase=angle(x2);
subplot(1,2,1);
stem(n,amp);
title('amp spectrum');
xlabel('samples->');
ylabel('magnitude');
subplot(1,2,2);
stem(n,phase);
title('phase spectrum');
xlabel('samples->');
ylabel('angle in radians');
IFFT-DIT

Output:

enter no of points 8
enter array in bit reversal order [7 -1 -1 -1 1 1 1 1]
output is
1 1 1 1 0 1 1 1
amp spectrum phase spectaum
1 1

0.9 0.8

0.8 0.6

0.7 0.4

angle in radians
0.6 0.2
magnitude

0.5 0

0.4 -0.2

0.3 -0.4

0.2 -0.6

0.1 -0.8

0 -1
0 2 4 6 8 0 2 4 6 8
samples-> samples->
%DIF IFFT
clc;
clear all;
close all;
n=input('enter no of points');
x0=input('enter array in order');
x1=0;
x2=0;
m=log2(n);
for i1=1:m
p1=n/(2^i1);
p=n/(p1*2);
q=n/p;
for j1=1:q:n;
r=j1;
for k=1:(q/2)
a=x0(r);
b=x0(r+(q/2));
k1=cos(2*pi*(k-1)/q)+i*sin(2*pi*(k-1)/q);
c=a+b;
d=(a-b)*k1;
x1(r)=c;
x1(r+(q/2))=d;
r=r+1;
end;
end;
x0=x1;
x2=x1;
x1=0;
end;
disp('output is');
x2=x2/n;
disp(x2);
n=0:1:n-1;
amp=abs(x2);
phase=angle(x2);
subplot(1,2,1);
stem(n,amp);
title('amp spectrum');
xlabel('sample->');
ylabel('magnitude');
subplot(1,2,2);
stem(n,phase);
title('phase spectrum');
xlabel('samples->');
ylabel('angle in radians');
IFFT-DIF
Output:

enter no of points8
enter array in order[7 1 -1 1 -1 1 -1 1]
output is
1 0 1 1 1 1 1 1

amp spectrum phase spectaum


1 1

0.9 0.8

0.8 0.6

0.7 0.4

angle in radians
0.6 0.2
magnitude

0.5 0

0.4 -0.2

0.3 -0.4

0.2 -0.6

0.1 -0.8

0 -1
0 2 4 6 8 0 2 4 6 8
sample-> samples->
%FIRST ORDER SYM

clc;
clear all;
close all;
a=[1 -.8];
b=[1];
w=0:.01:2*pi;
h=freqz(b,a,w);
subplot(2,2,1);
plot(w/pi,abs(h));
xlabel('freq');
ylabel('amp');
title('magnitude spectrum');
subplot(2,2,2);
plot(w/pi,phase(h));
xlabel('freq');
ylabel('amp');
title('phase spectrum');

%SECOND ORDER SYM

a=[1 -.8 .5];


b=[1 .5];
w=0:.01:2*pi;
h=freqz(b,a,w);
subplot(2,2,3);
plot(w/pi,abs(h));
xlabel('freq');
ylabel('amp');
title('magnitude spectrum');
subplot(2,2,4);
plot(w/pi,phase(h));
xlabel('freq');
ylabel('amp');
title('phase spectrum');
FREQUENCY RESPONSE FIRST AND SECOND ORDER

OUTPUT:

magnitude spectrum phase spectrum


6 1

0.5
amp 4

amp
0
2
-0.5

0 -1
0 0.5 1 1.5 2 0 0.5 1 1.5 2
freq freq
magnitude spectrum phase spectrum
4 2

3 1
amp

amp
2 0

1 -1

0 -2
0 0.5 1 1.5 2 0 0.5 1 1.5 2
freq freq
%STABILITY

clc;
clear all;
close all;
b=input('enter num co-eff');
a=input('enter den co-eff');
z=roots(b);
p=roots(a);
zplane(z,p);
xlabel('real parts');
ylabel('img parts');
title('stability');
if((b<=1)&(a<=1))
disp('stable sym');
else
disp('unstable sym');
end;
STABILITY OF THE SYSTEM

Output:
enter num co-eff[1 0.5]
enter den co-eff[1 0.2]
stable sym
stability

0.8

0.6

0.4

0.2
im g parts

-0.2

-0.4

-0.6

-0.8

-1

-1 -0.5 0 0.5 1
real parts

enter num co-eff[1 2]


enter den co-eff[1 3]
unstable sym
stability

1.5

0.5
img parts

-0.5

-1

-1.5

-3 -2.5 -2 -1.5 -1 -0.5 0 0.5 1


real parts

S-ar putea să vă placă și