Strange results with all pass compensation 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?
UPDATE: As Hilmar pointed out, OP did convolution in the time domain (as is clear in this code). This answer is misleading so will be deleted).
You would not convolve the two responses as you are in the frequency domain. It is the time domain impulse response of the equalization filter that you would convolve with, and convolution in the time domain is the product in the frequency domain. For the product of complex signals, the phases would add, so in your simple example (which may not be realizable due to causality) the phases would add to zero.
For the product of complex signals, the phases would add:
$$K_1e^{j\phi_1}K_2e^{j\phi_2} = K_1K_2e^{j(\phi_1 + \phi_2)}$$