function Wf = recpulse(T)

%ECOMMS Spring '00 Classroom Demo
%S. Mandayam, ECE Dept., Rowan University
%Spectrum of a Rectangular pulse
%
%Pulse Width: T < 20

close all;

t=-10:0.01:10;
w=zeros(1,length(t));
for t_index=1:length(t);
   if t(t_index)>=-T/2 
      if t(t_index)<=T/2
         w(t_index)=1;
      end;
   end;
end;

subplot(2,1,1);
plot(t,w);
axis([-10 10 -0.5 2]);
grid on;
xlabel('t');
ylabel('w(t)=\Pi(t/T)');
title('Time Domain');


f=-5:0.01:5;
Wf=T*sinc(T*f);
subplot(2,1,2);
plot(f,Wf);
grid on;
xlabel('f');
ylabel('W(f)=sinc(Tf)');
title('Spectral Domain');

pause;
figure;
f=-10/T:0.01:10/T;
Wf=T*sinc(T*f);
plot(f,Wf);
grid on;
xlabel('f');
ylabel('W(f)=sinc(Tf)');
title('Spectral Domain');
