function attbin2mat(filespec, outfile)

% attbin2mat(filespec, outfile)
%
%  filespec: string, e.g., '*attstats.bin', to be used by
%              the dirs command to make a sorted list of all
%              bin files containing Ashtech stats; these files
%              will have been written by load_raw.
%  outfile:  name, including extension, of the matlab file
%              to which all the att info will be written.
%              The resulting file should be identical to one
%              written by ubprint.
%
%  EF 2001/04/15
% (JH: NOTE - must read and write from current directory: no path info parsed)


if nargin ~= 2,
   help('attbin2mat')
   error('Two input arguments are required.')
end
files = dirs(filespec);

for ii = 1:length(files),
   filename = files(ii).name;
   [a, s] = read_bin(filename);
   if ii == 1
      att = a;
      for jj = 1:length(s.rows),
         eval(sprintf('%s = %d;', s.rows{jj}, jj));
      end
   else
      att = [att, a];
   end
end

save6(outfile, s.rows{1})
for ii = 2:length(s.rows)
   save6(outfile, '-append', s.rows{ii})
end
save6(outfile, '-append', 'att')

