Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

DIFFT

clc;clear all;close all;


N=input('length of the sequence');
f=input('input frequency is');
for i1=1:N
y(i1)=sin(2*pi*f*i1/N);
end
% twiddle factor
for i1=1:N/2
w(i1)=exp(-j*2*pi*(i1-1)/N);
end
nos=log2(N);
legd=N/2;
for i1=1:nos
for j1=1:legd
for k=j1:2*legd:N
ul=k;
ll=ul+legd;
temp1=y(ul)+y(ll);
temp2=y(ul)-y(ll);
y(ll)=temp2*w(j1);
y(ul)=temp1;
end
end
legd=legd/2;
len=length(w);
w=w(1:2:len);
end
y1=bitrevorder(y);
disp(y1);
n=0:1:N-1;
plot(n,abs(y1));

bitreversal

clc;clear all;close all;


N=input('length of the sequence');
f=input('input frequency is');
for i1=1:N
y(i1)=sin(2*pi*f*i1/N);
end
% twiddle factor
for i1=1:N/2
w(i1)=exp(-j*2*pi*(i1-1)/N);
end
nos=log2(N);
legd=N/2;
for i1=1:nos
for j1=1:legd
for k=j1:2*legd:N
ul=k;
ll=ul+legd;
temp1=y(ul)+y(ll);
temp2=y(ul)-y(ll);
y(ll)=temp2*w(j1);
y(ul)=temp1;
end
end
legd=legd/2;
len=length(w);
w=w(1:2:len);
end
y1=bitrevorder(y);
disp(y1);
n=0:1:N-1;
plot(n,abs(y1));
POWER SPECTRAL

clc;clear all;close all;n=8;


N=input('length of the sequence');
f=input('input frequency is');
for i1=1:N
y(i1)=sin(2*pi*f*i1/N);
end
for n=1:1:N
sum=0;
for k=1:1:N-n+1
sum=sum+y(k)*y(n+k-1);
end
r(n)=sum;

end
subplot(3,1,1);
plot(y);
subplot(3,1,2);
plot(r);

% twiddle factor
for i1=1:N/2
w(i1)=exp(-j*2*pi*(i1-1)/N);
end
nos=log2(N);
legd=N/2;
for i1=1:nos
for j1=1:legd
for k=j1:2*legd:N
ul=k;
ll=ul+legd;
temp1=r(ul)+r(ll);
temp2=r(ul)-r(ll);
r(ll)=temp2*w(j1);
r(ul)=temp1;
end
end
legd=legd/2;
len=length(w);
w=w(1:2:len);
end
r=bitrevorder(r);
disp(r);
n=0:1:N-1;
subplot(3,1,3);
plot(n,abs(r));

You might also like