function str=table(A,s);
%TABLE creates a table of the form:
%
%              ---------------------------------------------
%              |  A(1,1)  |  A(1,2)  |  A(1,3)  |  A(1,4)  | 
%              ---------------------------------------------
%              |  A(2,1)  |  A(2,2)  |  A(2,3)  |  A(2,4)  |
%              ---------------------------------------------   ...
%              |  A(3,1)  |  A(3,2)  |  A(3,3)  |  A(3,4)  |
%              ---------------------------------------------
%                  :                 :                  :
%
%  INPUTS: 
%    (i) A = mxn matrix for table
%   (ii) s = number of spaces padding the number in the table (which has
%            converted to a 10-space string)
%
%  OUTPUTS: str= a string matrix giving the table of the form above.
%
[n,m]=size(A);
p=2*s+10;
pad1=' ';
for i=1:s-1;
  pad1=[pad1,' '];
end;
for i=1:n;
  for j=1:m;
    pad2=' ';
    snum=num2str(A(i,j));
    if length(snum)<10; 
      for k=1:s+10-length(snum)-1;
        pad2=[pad2,' '];
      end;
    else;
      pad2=pad1;
    end;
    str(i,(j-1)*p+1:j*p)=[pad2,snum,pad1];
  end;
end;
