I Wrote a Code For Fast Fourier Transformation With a Sin Function
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
cikalekli
le 2 Mar 2022
Commenté : cikalekli
le 2 Mar 2022
I created a code plots a sin(2*pi*f*t) function in t=-4:0.001:4 with period (T) 5ms.
Then by using Fast Fourier Transformation (FFT), I converted the function from time domain to frequency domain and plotted it.
Here is my code that I have written:
Did I do correctly or Do I have a mistake?
fs = 1000; %sampling freq.
t = -4 : 1/fs : 4; %period which is between -4 to 4
f = 200;
x = sin(2*pi*f*t); %function is time domain
n = length(t); %length of interval
Fou_x = (fft(x)); %fourier transform of function
Foushift_x = fftshift(Fou_x); %shift to zero
finterval = fs/n; %increasing value of freq. interval
f = -fs/2 : finterval : fs/2-finterval; %freq. interval
figure;
plot(f, abs(Foushift_x)/n); %plot freq. function interval
xlabel('Frequency (in Hertz');
title('Magnitude');
0 commentaires
Réponse acceptée
Benjamin Thompson
le 2 Mar 2022
Looks correct. The amplitude of your input signal is divided between the left and right half of the output. Type the command "doc fft" for a more detailed example.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Fourier Analysis and Filtering 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!