在查看了 Jim Clay 在评论中提到的参考资料后找到了答案,谢谢 Jim。
我犯了一个错误,即只考虑导致零相位信号的幅度并且不能明智地用于发射,至少在这个设置中没有。
我最终使用的代码如下所示。
该脚本遵循保持时域信号小写和频域信号大写的命名约定。
% Align and sum all files called Mandag*
files = dir('Mandag*');
% Where in the recordings the signal is
rng = [1.5e6, 1.52e6];
% Initialize the xh vector
[xh, fs] = wavread(files(1).name, rng);
xh = xh(:,1);
for i=2:length(files)
y = wavread(files(i).name, rng);
y = y(:,1);
% Determine offset between xh and y
[~, off] = max(xcorr(xh', y'));
off = length(xh) - off;
% Shift signal appropriately
if(off < 0)
y = [zeros(1, -off), y(1:end+off)'];
elseif (off > 0)
y = [y(off:end)', zeros(1, off-1)];
end
xh = xh + y';
end
% Average
xh = xh/length(files);
% Location of the 20ms signal
xh = xh(2306:12306-1);
% Normalize
xh = xh / max(xh);
% Apply a moving average filter on xh to reduce noise. Window size of 4 was
% experimentally determined to give the best results
n = 4;
B = zeros(n, 1);
for i=1:n
B(i) = 1/n;
end
xh = filter(B, 1, xh);
xh = xh / max(xh);
x = wavread('sweep.wav');
x = x(1:2:end); % Sweep generated @ 1MHz, decimate
% to have same length as xh
% Transform x into frequency domain and determine H
X = fft(x);
H = fft(xh) ./ X;
% Vector indices to choose only frequencies of interest
starti = 20e3 / 50;
endi = 100e3 / 50;
rng = starti:endi;
irng = (length(x) - endi) : (length(x) - starti);
% Zero out unwanted frequencies
X = [zeros(1, starti - 1 ), X( rng)', zeros(1, length(X)/2 - endi) ...
zeros(1, length(X)/2 - endi), X(irng)', zeros(1, starti - 1 )]';
% Deconvolve x with h
X_deconv_H = X ./ H;
% Transform X/H to time domain and normalise
x_deconv_h = real(ifft(X_deconv_H));
x_deconv_h = x_deconv_h / max(x_deconv_h);
% Save the deconvolved sweep
wavwrite(x_deconv_h, fs, 'deconvolved_sweep.wav');
% Generate spectrograms of xh and x_deconv_h
winsize = 512;
overlap = round(.99 * winsize);
figure(1)
specgram(xh, winsize, fs, hann(winsize), overlap)
colorbar
figure(2)
specgram(x_deconv_h, winsize, fs, hann(winsize), overlap)
colorbar
x conv h
和的频谱图x deconv h
如下所示:
尽管去卷积信号中有一些噪音,但这些对我来说似乎是合理的。
下一个测试将是查看发射是否x_deconv_y
会产生类似于x
禁止扬声器无法发射的频率的东西。
更新测试结果
我们使用对数向下扫描重新进行了上述测量。这些结果似乎表明该方法有效。
验证测试包括发射X / H
和期望X
返回,即所有频率的能量相等。由于最差的输出频率比最好的低约 20dB,因此最高输出电平预计要低得多。
发出的信号:
记录信号的时间序列和频谱图如下所示: