I am new to DSP and, as a learning exercise, I am trying to design an all-pass filter in order to compensate the phase of an input impulse response (heqm.mat, which you can download from here). The MATLAB code is the following; for the phase compensation I am using the time-reversed technique, also called matched-filter:
load heqm.mat; % Load the heqm vector HEQM = fft(heqm); % Design the all-pass filter HEQMP = exp(1j.*angle(HEQM)); tmp = ifft(HEQMP,'symmetric'); % Time-reversed technique eqpr = tmp(end:-1:1); % Figure on the left figure; plot(unwrap(angle(fft(heqm)))); hold on; plot(unwrap(angle(fft(eqpr)))); % Convolution of the original impulse response with the all-pass filter o = conv(heqm,eqpr); % Figure on the right figure; plot(unwrap(angle(fft(o))));
As you can see from the left picture, the phase of the all-pass filter is the opposite of the original one. But if I convolve the two vectors, why the resulting phase (right figure) isn't flat as it should be? What am I missing here?