what is wrong with my code(FFT)?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
minsoo kim
le 28 Mar 2018
Commenté : minsoo kim
le 3 Avr 2018
% code
clc;
clear all;
close all;
f1 = 4*1000 %f1=4kHz
t1 = linspace(-1/f1, 1/f1, 100*1000); %t1=(-1/f1,1/f1)
x_c1=sinc(2*pi*f1*t1);
FT_x_c1 = fft(x_c1);
plot(FT_x_c1)
and result is
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/171635/image.png)
It is obvious that FFT of sinc function in time domain is rect function in frequency domain.
But as you see, there's something wrong with the result.
What should I do to solve this situation?
0 commentaires
Réponse acceptée
Prasanth Sunkara
le 2 Avr 2018
Modifié(e) : Prasanth Sunkara
le 2 Avr 2018
Hello Minsoo,
The issue here is you are trying to directly plot the MATLAB fft command output, ie DFT - complex values. If I were to analyse the signal in frequency domain, I would take one side spectrum from the fft output and then plot the Magnitude response (not the complex DFT output).
Please refer to the MATLAB doc page on FFT, which explains the use of the fft command to plot the spectrum. Focus on the part where the a single side of the spectrum is extracted and the Magnitude is plotted.
Additionally, you may also find the below similar MATLAB Answers post useful. https://www.mathworks.com/matlabcentral/answers/210082-hi-all-i-need-to-plot-a-fast-fourier-transform-fft-of-a-sinc-function
- Prasanth
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur 스펙트럼 측정값 dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!