How can I do the FFT of a rectpuls?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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!
0 comentarios
Respuestas (1)
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
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.
Ver también
Categorías
Más información sobre Spectral Measurements 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!