No BSD License  

Highlights from
fft

1.0

1.0 | 2 ratings Rate this file 1 Download (last 30 days) File Size: 1.09 KB File ID: #23461

fft

by ustc huan

 

28 Mar 2009

fft code written my me

| Watch this File

File Information
Description

use matlab to implement fft

Required Products Database Toolbox
MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
30 Mar 2009 Duane Hanselman

Why is the Database Toolbox required? Here is what is in this file:
function xn=myfft(x)
N=length(x);%È¡Êý×鳤¶È
M=log2(N);%ÇóÊý×鳤¶ÈÒÔ2Ϊµ×µÄÃÝ
%´Ë´¦½«Êý×éxÅÅÐò³Éxtmp
%»ù±¾Ë¼Ï룺½«Ã¿Î»x(i)ÖеÄiµÄÖµ»»Ëã³É2½øÖÆ£¬Ã¿´Î½«×îµÍλȡ³ö±£´æµ½³¤¶ÈΪMµÄÊý×éÖÐ
%¸ÃÊý×éµÄ´ÓµÚMλµ½µÚ1λÅÅ¿ª¾ÍÊÇÅÅÐòºóµÄλÖõĶþ½øÖƱíʾ
%½«¸ÃÊý×é»»Ëã³ÉÊ®½øÖƵÄÊý¾ÍÊÇÐòÊýÖØÅźóµÄÐòÊýpos£¬ÔÙ½«x(i)¸³Óèxtmp(pos)
%ÓÉÓÚmatlabÖÐÊý×é´Ó1¿ªÊ¼£¬¹ÊӦΪx(pos+1)=x(i+1)
xtmp=zeros(1,N);
value=zeros(1,M);
for i=0:N-1
    repr=i;
    for t=1:1:M
        repr=bitshift(i,1-t);
        value(t)=bitand(repr,1);
    end
    pos=0;
    for k=1:1:M
        pos=pos+value(k)*2^(M-k);
    end
    xtmp(pos+1)=x(i+1);
end
%xtmp=x;

%fftÖ÷º¯Êý
%Ö÷Ҫ˼Ï룺¹²ÓÐM²ã¼ÆËã
%ÿ²ã°üÀ¨width¿é¼ÆË㣬ÿ¿é¼äÏà¾à2^iµÄ¾àÀ루iΪµÚi²ã£©
%ÿ¿é¼ÆËã°üÀ¨deepth¸öµûÐÎÔËËã
for i=1:M
    deepth=2^(i-1);
    width=2^(M-i);
    for t=1:2^i:N
        for k=1:deepth
            tmp=xtmp(t+k-1);
            wn=width*(k-1);
            xtmp(t+k-1)=tmp+exp(-j*2*pi*wn/N)*xtmp(t+k+deepth-1);
            xtmp(t+k+deepth-1)=tmp-exp(-j*2*pi*wn/N)*xtmp(t+k+deepth-1);
        end
    end
end
xn=xtmp;

30 Mar 2009 Hal 9000

This file is full of garbage. How is this supposed to run?

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
fft Helen Chen 30 Mar 2009 13:59:02
signal processing ustc huan 30 Mar 2009 13:59:37

Contact us at files@mathworks.com