function b = fill_in(a,wgts);
%FILL_IN    fills in the matrices calculated in pums.f
%           See pums.f for a description.

%           Ellen McGrattan, 11-6-96

b=a;
for j=2:7;
  for i=j-1:-1:1;
    b(i,j) = extrap(b(i+4:-1:i+1,j),wgts);
  end;
end;
for j=1:6;
  for i=j+5:11;
    b(i,j) = extrap(b(i-4:i-1,j),wgts);
  end;
end;
age=15:10:75;
figure(3)
plot(15:10:75,b),title('Extrapolated series'),xlabel('age'),grid
text(age-.5,b(1,:),'0')
text(age-.5,b(2,:),'1')
text(age-.5,b(3,:),'2')
text(age-.5,b(4,:),'3')
text(age-.5,b(5,:),'4')
text(age-.5,b(6,:),'5')
text(age-.5,b(7,:),'6')
text(age-.5,b(8,:),'7')
text(age-.5,b(9,:),'8')
text(age-.5,b(10,:),'9')
text(age-.5,b(11,:),'10')
v=axis;
disp(sprintf(' %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f\n', ...
  [max(b,0),mean(max(b,0)')']'))

figure(4)
plot(age,a),title('Original series'),xlabel('age'),grid
text(age-.5,a(1,:),'0')
text(age-.5,a(2,:),'1')
text(age-.5,a(3,:),'2')
text(age-.5,a(4,:),'3')
text(age-.5,a(5,:),'4')
text(age-.5,a(6,:),'5')
text(age-.5,a(7,:),'6')
text(age-.5,a(8,:),'7')
text(age-.5,a(9,:),'8')
text(age-.5,a(10,:),'9')
text(age-.5,a(11,:),'10')
axis(v)
disp(sprintf(' %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f \n', ...
  a'))
