MATLAB: How can i see the effect of changing time period in frequency domain, i need to see the bandwidth changing while i am changing time period

bandwidth

clc; clear all
Fs=1000; Ts=1/Fs; t = (-3:Ts:3-Ts)*1e-3;
M=4; K=log2(M);
Bw=10e3;
rect1=rectangularPulse(-1*1e-3,1*1e-3,t); % rect pulse = Tsym symbol duration = 2 msec
rect2=rectangularPulse(-.5*1e-3,.5*1e-3,t);
nfft=length(rect1); nfft2=2^nextpow2(nfft); xfft=Fs*(0:nfft2/2-1)/nfft2;
f1=fft(rect,nfft2); ff=f1(1:nfft2/2);
f2=fft(rect2,nfft2); ff2=f2(1:nfft2/2);
plot(xfft,abs(ff)/3000,'r',xfft,abs(ff2)/3000,'y')
in this code i changed the width of the rect signal. how can i see the bandwidth effect?

Best Answer

It is easier to see the differences if you plot each of them individually in a separate subplot.
Change the plot call to:
figure(1)
subplot(2,1,1)
plot(xfft,abs(ff)/3000,'r')
axis([0 10 0 1])
title('Pulse Width ±1\cdot10^{-3}')
xlabel('Frequency')
ylabel('Amplitide')
grid
subplot(2,1,2)
plot(xfft,abs(ff2)/3000,'g')
axis([0 10 0 1])
title('Pulse Width ±5\cdot10^{-4}')
xlabel('Frequency')
ylabel('Amplitide')
grid
<<www-mathworks-com-matlabcentral-answers-uploaded_files-67634-how-20can-20i-20see-20the-20effect-20of-20changing-20time-20period-20in-20frequency-20domain--20i-20need-20to-20see-20the-20bandwidth-20changing-20while-20i-20am-20changing-20time-20period-20--202017-2001-2016.png>>