필터 지우기
필터 지우기

Amplitude-Frequency response peaks at zero, how to fix?

조회 수: 12 (최근 30일)
Chinwe Orie
Chinwe Orie 2018년 7월 9일
댓글: Star Strider 2018년 7월 10일
I made an amplitude-frequency response curve but I have a peak at 0 Hz. I'm not sure why but I know for sure that this is definitely wrong. The peak should be around 125 Hz. How do I get rid of the zero peak? I have attached the code and the excel data file. Thanks!
f = xlsread(e);
%plotting the signal
t = f(:,1);
X1 = f(:,2);
data_d = detrend(X1,1);
subplot(2,1,1)
plot(t,X1);
hold on
plot(t,data_d, 'g')
hold off
%Some of the envelope code was not working properly because MATLAB read
%some lines of the excel file as infinite numbers. The envelope function
%does not take infinite numbers.
%Thus, the below code deletes the infinite numbers from the array. There
%are only 2 of them.
fin = isfinite(X1);
t = t(fin);
signal = X1(fin);
Fs = 5000;
%Since the signal is real-valued, we use only the positive frequencies from
%the DFT to estimate the amplitude. Scale the DFT by the length of the
%input signal and multiply all frequencies excep 0 and the Nyquist by 2.
xdft = fft(signal);
xdft = xdft(1:floor(length(signal)/2+1));
xdft = xdft/length(signal);
xdft(2:end-1) = 2*xdft(2:end-1);
freq = 0:Fs/length(signal):Fs/2;
subplot(2,1,2)
plot(freq,abs(xdft))
hold on
plot(freq,ones(floor(length(signal)/2+1),1), 'LineWidth', 2)
xlabel('Hz')
ylabel('Amplitude')
xlim([0 200])
ylim([0 0.02])
hold off

채택된 답변

Star Strider
Star Strider 2018년 7월 9일
The peak at 0 Hz is the direct-current (d-c) or constant offset. You can eliminate it by subtracting the mean of the signal before taking the Fourier transform.
xdft = fft(signal - mean(signal));
  댓글 수: 12
Chinwe Orie
Chinwe Orie 2018년 7월 10일
Ah yes, that's true. But doesn't it do the plot using normalized frequency? Is there a way to convert normalized to the regular frequency scale?
Star Strider
Star Strider 2018년 7월 10일
The only ‘normalized frequency’ I’m aware of uses a scale from 0 to pi. The frequency otherwise goes from 0 to the Nyquist frequency (half the sampling frequency).

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by