Find the problem with my FFT code

조회 수: 1 (최근 30일)
dongwoo kim
dongwoo kim 2019년 9월 15일
댓글: dpb 2019년 9월 17일
Hello
I'm using FFT code to compare the amplitudes of two signals, but the answer is different from my idea.
I measured the pressure signal 1000 times a second.
And one is unchanged, the other is increasing.
I divided these two signals by 8 seconds each and PLOT through FFT.
If I find the amplitude with the code below, the value of the unchanging signal is bigger.
But in my opinion, the amplitude of the magnitude of the increasing signal should be bigger den unchanged signal.
Is my code wrong?
thank you for reading :)
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sample time
L = 8000; % Length of signal
t = (0:L-1)*T; % Time vector
x=TL26; %signal
y=table2array(x);
n=4; %% order of Butterworth filter
Wn=[130 150]; % 130 ~ 150Hz signal
Fn=Fs/2; % Nyquist
ftype='bandpass';
[b,a]=butter(n, Wn/Fn, ftype);%%% butter(): 버터워스 returns an order 2*n digital bandpass filter if
%%%fbn is a two-element vector
e=filtfilt(b,a,y);
N = length(e);
NFFT = 2^nextpow2(N); % Next power of 2 from length of y
%Y = fft(y,NFFT)/NFFT;
Y = fft(e,NFFT);
Ya = abs(Y)/NFFT; % correctly normalised amplitude
f = Fs/2*linspace(0,1,NFFT/2+1);
% Plot single-sided amplitude spectrum.
figure(99)
plot(f,2*abs(Ya(1:NFFT/2+1)));
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
  댓글 수: 32
dongwoo kim
dongwoo kim 2019년 9월 17일
Thank you for all your advice so far :)
I'll go back to the lab based on your advice.
I wish you happiness in everything.
dpb
dpb 2019년 9월 17일
Good luck...glad to at least try to help! :)

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Filter Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by