Using fft with rectangularPulse
21 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Taylor Artunian
am 5 Mär. 2020
Beantwortet: Samra Shazadi
am 10 Feb. 2022
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 Kommentare
Akzeptierte Antwort
Star Strider
am 5 Mär. 2020
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 Kommentare
Weitere Antworten (1)
Samra Shazadi
am 10 Feb. 2022
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 Kommentare
Siehe auch
Kategorien
Mehr zu Fourier Analysis and Filtering finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!