필터 지우기
필터 지우기

I can't place the fft curve at the signal frequency exactly. There's been a slight deviation of the fft peak at that frequency

조회 수: 2 (최근 30일)
%program to find the fft of sine function of frequency 1GHz
%Available information , frquency=1GHz
clear all
close all
clc
fmax=1e9; %maximun frequency of the signal
fs=60*fmax;
ts=1/fs; %time increment
T=10e-9; %total time signal exists
TA=(-T/2:ts:T/2); %time axis
N=numel(TA);
f=1e9; %frequency of the signal
Y=sin(2*pi*f*TA); %sine function
plot(TA,Y);
FA=(-N/2:N/2-1)*fs/N; %frequency axis
FFT=fft(Y); %fourier transform of the signal
figure;
plot(FA,fftshift(abs(FFT)));
xlim([-2e9 2e9]);
xline(-1e9);
As shown below there's a slight deviation at the peak of the fft curve, I can't figure why there is deviation at the peak
Isn't the peak supposed to be at exactly at 1GHz.
xline(1e9);

채택된 답변

Paul
Paul 2024년 5월 4일
편집: Paul 2024년 5월 4일
fmax=1e9; %maximun frequency of the signal
fs=60*fmax;
ts=1/fs; %time increment
T=10e-9; %total time signal exists
TA=(-T/2:ts:T/2); %time axis
N=numel(TA)
N = 601
f=1e9; %frequency of the signal
Y=sin(2*pi*f*TA); %sine function
plot(TA,Y);
This expression for FA is incorrect when N is odd (601)
FA=(-N/2:N/2-1)*fs/N; %frequency axis
The correct expression for N odd is
FA = (-(N-1)/2:(N-1)/2)/N*fs;
A general expression that works for N odd or even is
FA = ((0:N-1) - floor(N/2))/N*fs;
Use ifftshift on Y prior to the call to fft if the phase of the result is important
FFT=fft(Y); %fourier transform of the signal
figure;
plot(FA,fftshift(abs(FFT)),'-o');
xlim([-2e9 2e9]);
xline(-1e9);
The small-but-nonzero points around the peaks arise because the discrete-time period of the sampled signal is P = 60, but the number of points in the data is 601, which is not an integer multiple of the period.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spectral Estimation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by