clear
clc;
N=512;
L=512;
f1=300;fs=15000;
T=1/fs;
ws=2*pi*fs;
t=(0:1:N-1)*T;
x=sin(2*pi*f1*t);
y=fft512(x,512);
m=0;
for iii=0:255
p=x(iii,1);
q=x(iii,2);
n=p^2+q^2;
mod(m)=sqrt(n);
m=m+1;
end
w=((0:L-1)*ws/L)/(2*pi);
plot(w(1:L/2),abs(mod(1:L/2)));
grid on;
ylabel('f1自编算法幅度谱')
xlabel('w')
figure(1);
plot(t,x);
grid on;
ylabel('幅度')
xlabel('t')
function [y]=fft512(x,N)
[w5121,w5122]=textscan('fft512.txt','%f%f','headerlines',0);
w512=[w5121,w5122];
BLDiff=N;
TwFStep=1;
k=N;
while k>1
k&