MATLAB: High-pass filter

accelerometric signalbutterworth filterffthigh pass filterMATLAB

Hello,
I'm working on acceleration signals coming from an accelerometer that has a sensitivity change of 0% from 2 Hz to 10000 Hz. When I perform the FFT of one this accelerometric signals I often obtain strong low frequency contents close to 0.1 Hz. I would like to cut away all the frequencies before 2 Hz because I don't think they are correct. The code I used is:
Fca=2; %cutoff frequency
[z,p,k]=butter(8,Fca/(Fsa/2),'high');
sos=zp2sos(z,p,k);
%fvtool(sos,'Analysis','freq')
xafiltfilt=filtfilt(sos,g,xa);
%figure;
%plot(ta,xa,ta,xafiltfilt);
%grid on
%title('xa (accelerometric signal)')
%xlabel('t (s)')
%ylabel('Acceleration (g)')
%legend({'Original xa Signal','Actual xa Signal (filtered and realigned signal)'});
%saveas(gcf,'x_acc_filt_comp','jpg')
Xaf=fft(detrend(xafiltfilt),NFFT2_acc)/Na;
figure;
plot(fa,2*abs(Xaf(1:NFFT2_acc/2+1)))
grid on
title('Single-Sided Amplitude Spectrum of xa(t) filtered and realigned Signal')
xlabel('f (Hz)')
ylabel('Xa_filtered(f)')
I was wondering if this type of filter may be adequate.
Thank you very much,
Guglielmo

Best Answer

It could work, however a better option could be:
Fca = 2;
Fsa = 1000; % Create Parameter
xa = randn(1E+4,1); % Create Signal
[xafiltfilt,hpdf] = highpass(xa, Fca, Fsa, 'ImpulseResponse','iir');
figure
freqz(hpdf.Coefficients, 2^16, Fsa)
set(subplot(2,1,1), 'XLim',[0 10]) % Zoom Frequency Axis



set(subplot(2,1,2), 'XLim',[0 10]) % Zoom Frequency Axis
Compare to the Butterworth design:
[z,p,k]=butter(8,Fca/(Fsa/2),'high');
sos=zp2sos(z,p,k);
figure
freqz(sos, 2^16, Fsa)
set(subplot(2,1,1), 'XLim',[0 10]) % Zoom Frequency Axis
set(subplot(2,1,2), 'XLim',[0 10]) % Zoom Frequency Axis
.