How can I do the FFT of a rectpuls?
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Star Strider
2016-3-14
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 个评论
Star Strider
2016-3-14
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Measurements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!