Borrar filtros
Borrar filtros

How can I do the FFT of a rectpuls?

5 visualizaciones (últimos 30 días)
Riccardo Barbero
Riccardo Barbero el 14 de Mzo. de 2016
Comentada: Star Strider el 14 de Mzo. de 2016
I know that the Fourier transform of a rectpuls is a sinc function. I'm able to plot a rectpuls using the command A*rectpuls(t,B), in witch "t" represent the time on x axis, "B" represent the a length of the base of the rectangle and "A" represent the amplitude. So, a possible MATLAB code to plot it could be:
t=-5:.01:5;
x=2*rectpuls(t,2);
plot(t,x)
Now, i would like to compute the FFT, obtaining a sinc function... How can I do this, using the command fft?
Thank you!

Respuestas (1)

Star Strider
Star Strider el 14 de Mzo. de 2016
This is how I would do it:
t=-5:.01:5;
x=2*rectpuls(t,2);
figure(1)
plot(t,x)
grid
Ts = mean(diff(t)); % Sampling Interval
Fs = 1/Ts; % Sampling Frequency
Fn = Fs/2; % Nyuquist Frequency
L = length(x);
ftx = fft(x)/L; % Fourier Transform
ftxs = fftshift(ftx); % Shift To Centre
Fv = linspace(-Fn, Fn, L); % Frequency Vector
figure(2)
subplot(2,1,1)
plot(Fv, abs(ftxs)) % Plot Amplitude
grid
subplot(2,1,2)
plot(Fv, angle(ftxs)) % Plot Phase
grid
  5 comentarios
Riccardo Barbero
Riccardo Barbero el 14 de Mzo. de 2016
Ok, I understand! ;)
I don't know if you read my P.S...
Why, using your code, I obtain that the maximum amplitude of sinc is 0.4 (in f=0), instead of 4 (as the area of the rectangle)?
Thank you for your patience
Star Strider
Star Strider el 14 de Mzo. de 2016
I overlooked your P.S. before, probably because you posted it while I was writing my previous Comment.
The amplitude of the sinc function calculated with the Fourier transform is correct. The power of the Fourier transformed signal is equal to the power of the time-domain signal, as stated in Parseval’s theorem. I invite you to explore that on your own.

Iniciar sesión para comentar.

Categorías

Más información sobre Spectral Measurements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by