|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
一段做ADC频谱分析的程序,fft的结果出现了-inf,请大家看一下程序有什么问题。
clear;
afs = 1; % 1V full scale
fs = 1e6; % 1MHz sample rate
N = 2^10; % number of samples
cyc = 67;
fx = fs*cyc/N;
t = linspace(0,(N-1)/fs,N);
y = afs*sin(2*pi*fx*t);
B = 10; % internal ADC resolution
delta = afs/2^B;
y = cos(2*pi*fx/fs*[0:N-1]);
%quantize samples to delta=1LSB
y=round(y/delta)*delta;
s = 20*log10(abs(fft(y)/N/afs*2));
s = s(1:N/2); % drop redundant half
f = (0:length(s)-1) / N; % frequency vector (normalized to fs)
figure(1);
plot(f,s);
grid on; |
|