Clear Filters
Clear Filters

why are the peaks of FFT of generated signal slighty off?

2 views (last 30 days)
I want to generate a signal of fixed length with two dampened frquency components 2 and 8. Then I would like to identify these frequencies using fft. Unfortunately, regarding the magnitude-frequency domain, the determined frequencies seem slightly off.
my code:
close
clear
clc
fs = 800; %sampling frequency
ts = 10; %signal length
efq1 = 2; %frequencies 2 and 8
efq2 = 8;
t = 0:1/fs:ts; %vector length
w1 = 2*pi*efq1; %pulsatances
w2 = 2*pi*efq2;
x = exp(-0.1.*w1.*t).*20.*sin(w1.*t)+exp(-0.2.*w2.*t).*50.*sin(w2.*t);
figure;
subplot(1,2,1)
plot (t,x);
grid on;
nfft=8192;
Y = fft(x,nfft);
Y = Y(1:nfft/2);
mY=abs(Y);
f1 = (0:nfft/2-1)*fs/nfft;
subplot(1,2,2);
plot(f1,mY);
grid on;
in the attached image you see the amplitude-time domain and the magnitude-frequency domain, zoomed in to visualize the deviation. can you tell me why this is and how to eliminate the deviation?

Answers (1)

Christoph F.
Christoph F. on 4 Dec 2017
Multiplying a function with another function can change the frequency content, as this corresponds to convolving the two image functions in the frequency domain.

Community Treasure Hunt

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

Start Hunting!