Borrar filtros
Borrar filtros

Inquiry about Fourier Transform

5 visualizaciones (últimos 30 días)
Angel Lozada
Angel Lozada el 5 de Mayo de 2021
Comentada: Angel Lozada el 12 de Mayo de 2021
Hello.
Hello.
According to Matlab documents regarding to Fourier Transform calculation, the code to do so is:
Ts = 1/25;
t = 0:Ts:10-Ts;
x = sin(2*pi*15*t) + sin(2*pi*20*t);
plot(t,x)
xlabel('Time (seconds)')
ylabel('Amplitude')
y = fft(x);
fs = 1/Ts;
f = (0:length(y)-1)*fs/length(y);
plot(f,abs(y))
xlabel('Frequency (Hz)')
ylabel('Magnitude')
title('Magnitude')
n = length(x);
fshift = (-n/2:n/2-1)*(fs/n);
yshift = fftshift(y);
plot(fshift,abs(yshift))
xlabel('Frequency (Hz)')
ylabel('Magnitude')
I have some inquiries:
I do not understand variable f and fshift?
  • What does mean?
  • Is always write it like that?
  • How can I show the expression for y = fft(x)?

Respuesta aceptada

Pratyush Roy
Pratyush Roy el 10 de Mayo de 2021
Hi,
The variables f and fshift are MATLAB arrays which represent the frequency components of a signal, where the array f varies within the interval [0,Fs] and fshift varies within the interval [-Fs/2,Fs/2]. While performing fftshift, we shift the zero-frequency component to the center of the spectrum. As a result, the spectrum is now centered around zero. We can choose different variable names for them as well.
When you mention show the expression y=fft(x), I understand you want to show the values in the y-array containing the FFT values. You can either print them out using disp
disp(y)
You can also plot the magnitude using the plot function
y = fft(x);
fs = 1/Ts; %Ts = Sampling interval
f = (0:length(y)-1)*fs/length(y);
plot(f,abs(y))
Hope this helps!
  1 comentario
Angel Lozada
Angel Lozada el 12 de Mayo de 2021
Pratyush Roy
Thanks for your soon ansewer, as well for cooperation and kindness.
Regarding one of my question: Is always like that?. I mean: why f is defined as
f = (0:length(y)-1)*fs/length(y) and not as f = 0:fs/10:fs?
Regarding the question: How can I show the expression for y = fft(x)? I mean, I want to see the fourier transform function.
Regards

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by