📄 myfft.m
字号:
clc
clear
m = 10 ;
n = 0:1:2^m-1 ;
x = 0:1:2^m-1 ;
a = 0 ;
b = 0 ;
y = 0.5*sin(2*pi*n/2^(m-4)) + sin(2*pi*n/2^(m-7)) + 2*sin(2*pi*n/2^(m-8)) ;
wnn = exp(n.*(-j*2*pi/2^m)) ;
t = n ;
z = fft(y,2^m) ;
f1 = fix(x/2) ;
m1 = mod(x,2) ;
f2 = fix(f1/2) ;
m2 = mod(f1,2) ;
f3 = fix(f2/2) ;
m3 = mod(f2,2) ;
f4 = fix(f3/2) ;
m4 = mod(f3,2) ;
f5 = fix(f4/2) ;
m5 = mod(f4,2) ;
f6 = fix(f5/2) ;
m6 = mod(f5,2) ;
f7 = fix(f6/2) ;
m7 = mod(f6,2) ;
f8 = fix(f7/2) ;
m8 = mod(f7,2) ;
f9 = fix(f8/2) ;
m9 = mod(f8,2) ;
f10 = fix(f9/2) ;
m10 = mod(f9,2) ;
%x = 4*m1+2*m2+m3 ;
x = m10+2*m9+4*m8+8*m7+16*m6+32*m5+64*m4+128*m3+256*m2+512*m1 ;
for i = 1:1:2^m
t(i) = y(x(i)+1) ;
end ;
subplot(221)
plot(n,y) ;
subplot(222)
plot(n,t) ;
for but = 1:m
for group = 1:2^(m-but)
for num = 1:2^(but-1)
c = 2^but*(group-1)+num ;
d = 2^but*(group-1)+num+2^(but-1) ;
wn = (num-1)*2^(m-but) ;
a = t(c) ;
b = t(d) ;
t(c) = a+b*exp(wn*(-j*2*pi/2^m)) ;
t(d) = a-b*exp(wn*(-j*2*pi/2^m)) ;
end ;
end ;
end ;
subplot(223) ;
plot(n,abs(t));
subplot(224)
plot(n,abs(z));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -