I Wrote a Code For Fast Fourier Transformation With a Sin Function
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
cikalekli
el 2 de Mzo. de 2022
Comentada: cikalekli
el 2 de Mzo. de 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 comentarios
Respuesta aceptada
Benjamin Thompson
el 2 de Mzo. de 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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!