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!