How to plot a sinc function correctly?

14 visualizzazioni (ultimi 30 giorni)
I am generating a rectangular pulse using a piecewise function on Matlab. I have listened to some advice to use a normalization coefficient and the amplitude appears correct now. However, my issue is that it seems that my Fourier Transform plot is squished at the origin. Can someone point out where did I go wrong? Thank you for taking the time.
My Code:
% Sampling Frequency
fs=1000;
% Time Variables of Piece-wise functions
t1=-1:1/fs:-0.5;
t2=-0.5:1/fs:0.5;
t3=0.5:1/fs:1;
% Evaluations of each time intervals
y1 = zeros(size(t1));
y2 = ones(size(t2));
y3 = zeros(size(t3));
% Combination of the time variables and functions
t=[t1 t2 t3];
f=[y1 y2 y3];
% Plot the rectangular pulse
figure(1);
subplot(1,2,1);
plot(t,f);
% Fourier Transform Plot
subplot(1,2,2);
% Frequency Domain between -10 and 10 using the size of the function (f).
freq=linspace(-10,10,size(f,2));
% Fourier Transform with normalizing coefficient (1/fs).
ft=fftshift(fft(f))./(fs);
plot(freq,abs(ft));

Risposta accettata

Image Analyst
Image Analyst il 25 Ott 2023
In general, the spectrum and the time/spatial domain are inversely related. So the wider your pulse if with respect to your total window of data, the narrow your sinc function in the spectral domain. (That's why yours is so narrow). And the narrower your pulse, the wider the sinc will be.
Intuitively, as an optics person, I always like to think of it optically like a plane wave hitting an aperture. A rectangular pulse is like a slit and it you hit it with a plane wave (like a laser) and look at the pattern that gets transmitted (the "diffraction pattern") then you will see (in a plane far away from the slit) a series of stripes. The cross section of the stripes perpendicular to the slit is the sinc pattern, and if the slit is infinitely long then in the other direction (parallel with the slit) it will be a constant value.
If you narrow the slit, the stripes in the Fourier domain (the plane where you're viewing the diffraction pattern) widen out (separate). If you widen the slit, the stripes get smaller and merge closer.
If you have a 2-D rectangle function you get a sinc pattern in the other direction also:
so you no longer have uniform stripes. Narrowing the rectangular aperture in one direction widens the spectrum (diffraction pattern) in the perpendicular direction.

Più risposte (0)

Prodotti


Release

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by