Eliminating the d-c (or constant) offset by subtracting the mean is a good first step. The detrend function is definitely useful, but not always appropriate for signal processing, and probably not at all for your application. It will not eliminate low-frequency periodic baseline variations. For that, you need a highpass (or better, bandpass) filter. A highpass filter will eliminate the low-frequency baseline variation. A bandpass filter will also eliminate any high frequency noise.
A prototype FIR bandpass filter design (using kaiserord and fir1) is here:
Fs = 44100;
fcuts = [10 20 20E+3 21E+3];
mags = [0 1 0];
devs = [0.05 0.01 0.05];
[n,Wn,beta,ftype] = kaiserord(fcuts,mags,devs,Fs);
n = n + rem(n,2);
hh = fir1(n,Wn,ftype,kaiser(n+1,beta),'scale');
figure(1)
freqz(hh, 1, 2^14, Fs)
Change the frequencies in ‘fcuts’ and sampling frequency (‘Fs’) to be appropriate to your signal. See the documentation for kaiserord (link) for details. I also suggest that you use the code between the first (top) two plot figures in the fft (link) function. That will help you plot and understand your original and plotted signals.
Best Answer