我试图通过扬声器播放 20Hz 到 20KHz 的啁啾声并将扬声器输出声音文件与原始输入声音文件进行比较来获得扬声器的频率响应。这是我到目前为止所拥有的,但情节看起来并不像我期望的那样。Y 轴似乎不是以 dB 为单位的。我也可能做错了,我不确定。任何帮助是极大的赞赏。谢谢!
[y,fs] = wavread('LogChirp.wav');
[x,fs] = wavread('bose sweep 2 feet.wav');
y = reshape([y;zeros(145824-144000,1)],145824,1);
ydft = fft(x)./fft(y);
% Assume y has even length
ydft = ydft(1:length(y)/2+1);
% create a frequency vector
freq = 0:fs/length(y):fs/2;
% plot magnitude
ydft1 = smooth(ydft,.1);
p = semilogx(freq,ydft1);
p = plot(freq,abs(ydft));
set(p, 'Color', 'blue', 'LineWidth', 1);
xlabel('Frequency (Hz)');
ylabel('');
title('Frequency Response');
grid on;
%axis([20,20e3,-1,1]);