matlabfft简单例子(A simple example of matlabfft)
matlabfft简单例子(A simple example of matlabfft)
N = 128;
N = 0: n - 1;
T = n/fs.
F0 = 10; % set the frequency of the sinusoidal signal
% generates sinusoidal signals
X = sin (2 * PI * f0 * t);
Figure (1);
Subplot (231);
The plot (t, x); The time domain waveform for sinusoidal signals
Xlabel (' t ');
Ylabel (' y ');
Title (' sine signal y = 2 * PI * 10t time domain waveform ');
The grid;
% carry FFT transform and do the spectrum
Y = FFT (x, N); I'm going to do the FFT transformation
Mag = abs (y); Amplitude % o
F = (0: length (y) - 1) '* fs/length (y); The corresponding frequency conversion is performed
Figure (1);
Subplot (232);
The plot (f, mag); % of the spectrum
The axis (,0,80 [0100]);
Xlabel (' frequency (Hz));
Ylabel (' amplitude);
Title (' sine signal y = 2 * PI * 10t spectrum diagram N = 128 ');
The grid;
MATLAB FFT program 2009-11-08 16:30 CLC
X % input signal
M = nextpow2 (x); The lowest power m of 2 for the length of x
N = 2 ^ M;
If length (x) < N
X = [x, zeros (1, N - length (x)]; If the length of x is not the power of 2, the integer power of 0 to 2
The end
An NXD = bin2dec (fliplr (dec2bin (1: N - 1, M))) + 1; 1:2 % o ^ M sequence number in the reverse order
Y = x (an NXD); % will arrange x in reverse order as the initial value of y
WN = exp (-i 2 * PI * / N);
For L = 1: M
B = 2 ^ L / 2; The two input data of each butterfly are separated by B points, each of which has B different rotation factors
For J = 0: B - 1 % J represents different rotation factors
P = J * 2 ^ (M - L);
WNp = WN ^ p;
For k = J + 1:2 ^ m: N % of this butterfly operation across the interval of 2 ^ L
KP = k + B; The relationship between the two factors corresponding to the unit subscript
T = y (KP) * WNp; The product of the % butterfly operation
Y (KP) = y (k) - t; % butterfly operation, you must first do the subtraction operation, then add operation, otherwise you will use the intermediate variable to pass y (k).
Y (k) = y (k) + t; % butterfly operation
The end
The end
The end
y
Y1 = FF