% File: FIG3_12.M

clear;

t = 0:0.05:8;
k = 0:1:7;
Tb = 1;
Ts = Tb;
w = [0 1 0 0 1 1 1 0];
x = -5*Ts:0.05:5*Ts;

% Generating w2(t), sin(x)/x Pulse shape used
w2 = zeros(length(t),1);
for (i = 1:1:length(k))
  w2 = w2 + w(i)*Sa(pi/Ts * (t - (k(i)*Ts + 0.5*Ts)));
end;

% Generating w1(t), Rectangular pulse shape used.
w1 = zeros(length(t),1);
for (i = 1:1:length(k))
  temp = t - (k(i)*Ts + 0.5*Ts);
% Finding positions that correspond to -Ts/2 and Ts/2.
  left = index(temp,-Ts/2);
  right = index(temp,Ts/2);
  for (j = left:1:right)
    w1(j) = w(i);
  end;
end;

subplot(211);
plot(t,w1);
xlabel('t');
ylabel('w1(t)');
title('Rectangular Pulse Shape  Tb = 1 msec');
grid;

subplot(212);
plot(t,w2);
xlabel('t');
ylabel('w2(t)');
title('sin(x)/x Pulse Shape  Tb = 1 msec');
grid;
subplot(111);

  




