A non-zero mean will give you a large value at 0Hz in the frequency domain. If you zoom in at 20Hz, you will still see your signal, but if you remove the mean of your signal before computing the fft you should see a nice spike at 20Hz.
FFT of a signal
6 次查看(过去 30 天)
显示 更早的评论
I have some questions related to digital signal processing and I hope anybody can help.
I have to analyze measurements of a pressure signal with a kind of sine non-zero mean waveform. First I'm trying to test if my FFT Matlab code works correctly that's why Im implementing a sine with known amplitude and frequency and some noise like this:
t = 0:0.001:60;
fs=length(t)/t(end); % Sampling freq of 1000Hz
A=0.15; % amplitude of sine
f=20; % freq of sine
noise=randn(size(t));
mean=4;
y = A*sin(2*pi*f*t)+noise+mean;
(upper code produce smth like I got from the pressure transducers)
Next step is to produce a fft of signal:
N=length(t);
ft = abs(fft(y))/(N/2); % absolute value of the fft
ft = ft(1:N/2); % take the power of positive freq. half
freq = (0:N/2-1)/t(end); % find the corresponding frequency in Hz
and plot:
subplot(2,1,1) % plot original signal
plot(t,y)
xlim([0 1])
subplot(2,1,2) % plot FFT specter
plot(freq,ft)
My goal is to extract most accurate amplitude and frequency values.
Questions: Why I don't get the exact value of amplitude after FFT? How can I calculate an error when I'm analyzing signal if I dont know exact amplitude?
Should I use window? Which one? I tried to use hann function (window), but it didn't gave me the right amplitude as an output.
Should I filter the signal first (smth like butter filter with the cut off freq 2x the sine freq)? That doesn't change the accuracy of amplitude.
Why coz of non-zero mean value I get very big value at the beginning (looks like it's approx 2x mean value)? How can I get rid of that or is there an explanation for that?
Should I use only 2^N number of t? to avoid fft function do it automatically.
I know this are more questions about DSP, but I will appreciate any answer from you! Thank you in advance!
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!