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