Remove peak at 0 hz of fft
Mostrar comentarios más antiguos
Hi everybody,
I want to calculate the fft of my data, but I get a large peak at 0 Hz. I have read all the answers to the previous questions. Mostly recommended using x=x-mean(x) or x=detrend(x). I have tried that but nothing works.
Another suggestion was to look at the diff(x) and diff(diff(x)). I tried that and both give a noisy straight line.
I dont now what else to do so can somebody help me?
Thanks in advance!
x=load('data.txt');
% diffx=diff(x);
% diffdiffx=diff(diff(x));
xm=x-mean(x);
xd=detrend(x);
y=detrend(xm,'constant');
N=length(x);
fs=1000;
Ts=1/fs;
f=(0:1/N:1/2-1/N)*fs;
% figure
% plot(x)
% hold on
% plot(diffx)
% plot(diffdiffx)
% hold off
% legend('x','diffx','diffdiffx')
xhat=fft(x,N);
xhat(1)=0;
figure
plot(f,abs(xhat(1:N/2)));
title('Normal data')
xhat=fft(xm,N);
xhat(1)=0;
figure
plot(f,abs(xhat(1:N/2)));
title('Removed mean data')
xhat=fft(xd,N);
xhat(1)=0;
figure
plot(f,abs(xhat(1:N/2)));
title('Detrend data')
xhat=fft(y,N);
xhat(1)=0;
figure
plot(f,abs(xhat(1:N/2)));
title('Removed mean and detrend data')
[S,fm]=periodogram(x,[],N,fs,'power');
figure
plot(fm,10*log10(S))
title('Periodogram')
[S,fm]=periodogram(xm,[],N,fs,'power');
figure
plot(fm,10*log10(S))
title('Periodogram removed mean')
[S,fm]=periodogram(xd,[],N,fs,'power');
figure
plot(fm,10*log10(S))
title('Periodogram detrend data')
[S,fm]=periodogram(y,[],N,fs,'power');
figure
plot(fm,10*log10(S))
title('Periodogram removed mean and detrend data')
[Sw,fw]=pwelch(x,ones(N,1),0,N,fs,'power');
figure
plot(fw,Sw)
title('Welch method')
[Sw,fw]=pwelch(xm,ones(N,1),0,N,fs,'power');
figure
plot(fw,Sw)
title('Welch method removed mean')
[Sw,fw]=pwelch(xd,ones(N,1),0,N,fs,'power');
figure
plot(fw,Sw)
title('Welch method detrend data')
[Sw,fw]=pwelch(y,ones(N,1),0,N,fs,'power');
figure
plot(fw,Sw)
title('Welch method removed mean and detrend data')
Respuesta aceptada
Más respuestas (1)
Mehmed Saad
el 6 de Jul. de 2020
0 votos

FFT of X

FFT of X High pass filtered

Categorías
Más información sobre Correlation and Convolution en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
