Trying to get rid of a dc offset - tried other methods posted but to no avail

조회 수: 2 (최근 30일)
Bran
Bran 2014년 1월 19일
댓글: dpb 2014년 1월 19일
I am applying the FFT function to data from an accelerometer and I have a large spike at 0Hz. I understand that this could be due to the DC offset. I have tried to subtract the mean from my data and apply a High pass filter, however, it doesnt get rid of the problem. Oh and I applied a hamming window, please see my code below. The only other thing I can think of is that I have not windowed my data or split it into sensible sections. Can this make a difference? At the moment I am using all of the data which included section where the patient group ran, walked and were involved in some everyday tasks.
clc
clear all;
x1=load('data.txt');
x=x1(:,1);
win = hamming(length(x));
win=ones(length(x),1);
y = (x-mean(x));
NFFT = 2.^nextpow2(length(x));
FFTX = fft(y,NFFT);
%FFTX = fft(y,NFFT)/length(x);
Fs=60;
figure(1)
%plotting
f = Fs/2*linspace(0,1,NFFT/2);
cyclespersecond=2*abs(FFTX(1:NFFT/2));
%applying a filter
z = cyclespersecond;
RC = (1/(2*pi*0.25));
dt = f(2) - f(1);%just check to see if 1/(NFFT/2)
alpha = (RC/(RC+dt));
n = length(z);
z2(1) = z(1);
for i= 2:n
z2(i)= (alpha * z2(i-1) + alpha * (z(i) - z(i-1)));
end
%note NFFT/2=1 has been changed to NFFT/2
%Plot single-sided amplitude spectrum.
plot(f,cyclespersecond) % only need to plot one half of the spectrum
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
figure (2)
plot(f,z2) % only need to plot one half of the spectrum
title('Single-Sided Amplitude Spectrum of y(t) with filter')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
  댓글 수: 1
dpb
dpb 2014년 1월 19일
Take the mean off before applying the window for starters...there will be no DC component. That doesn't mean, of course, that there's not a bunch of very low frequency content in the data.
Also, you may get better idea of possible real data by using semilogy instead of linear y axis.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by