Using fft with rectangularPulse
조회 수: 22 (최근 30일)
이전 댓글 표시
I have created the following script to plot a rectangular pulse, the magnitude of the Fourier transform and the phase of the transform.
% Plot Fourier Transform
f=@(t) rectangularPulse(-1,1,t);
time=-6:0.01:6;
pulse=f(time);
fourier=fft(pulse);
figure()
subplot(3,1,1)
plot(time,pulse) % Pulse
subplot(3,1,2)
plot(time,real(fourier)); % Magnitude of Fourier
subplot(3,1,3)
plot(time,imag(fourier)); % Phase of Fourier
I know that the Fourier transform of a rectangular pulse is a sinc function but the output I get is not.

댓글 수: 0
채택된 답변
Star Strider
2020년 3월 5일
It is now:
f=@(t) rectangularPulse(-1,1,t);
time=-6:0.01:6;
Fs = 1/0.01;
Fn = Fs/2;
Freq = linspace(-Fn, Fn, numel(time));
pulse=f(time);
fourier=fft(pulse);
figure()
subplot(3,1,1)
plot(time,pulse) % Pulse
subplot(3,1,2)
plot(Freq,fftshift(real(fourier))); % Magnitude of Fourier
xlim([-10 10]) % (Optional)
subplot(3,1,3)
plot(Freq,fftshift(unwrap(angle(fourier)))); % Phase of Fourier
xlim([-10 10]) % (Optional)
I also calculated the frequency vector for the ‘fourier’ plots.
댓글 수: 0
추가 답변 (1개)
Samra Shazadi
2022년 2월 10일
a = 0.3;
t=[-2:0.01:2];
x = rectpuls(t, a); %rectangle waves
subplot(2,1,1); %subplot for rectangle waves
plot(t,x);
axis([-1 2 0 2]);
title("Rectangle waves");
xlabel('time');
ylabel('Value');
X=fft(x);
subplot(2, 1, 2); %subplot for Frequency signal
plot(t, fftshift(abs(X)));
title("Frequency Signal");
xlabel('freq (Hz)');
ylabel('|Y(freq)|');
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!