%
%  Name: makemref.m
% 
%  Usage: makemref
% 
%  Description:
%    Creates a DIAMOND data file with multiple reference FRF data matrices
%     from multiple DIAMOND data files with single reference FRF data
%

%  Version SWD970710
%
%  Author(s): Scott W. Doebling, doebling@lanl.gov
%
%  Institution: Los Alamos National Laboratory,
%		ESA-EA
%
%  Copyright (c) 1997, The Regents of the University
%     	of California. (See top level of code for
%        full copyright statement)
%

%
%  Determine how many files are available
%

nref = input('How many files to combine?');

disp(['Preparing to load ',num2str(nref),' files'])

%  Prompt for each one of the single reference files

pathname = 'C:\';

Gnew = [];
Gxynew = [];
Gxxnew = [];
Gyynew = [];
Cohnew = [];

refDOFnew = [];

for ib = 1:nref,
   
   fprintf(1,'Preparing to Load File #%d of %d\n',ib,nref)
   
   [filename,pathname,error] = loadfile(0,pathname);

   if error == 0,
      
      fprintf(1,'Loading File #%d of %d\n',ib,nref)

      eval(['load ',[pathname,filename]]);

      Gnew = [Gnew, G];
      Gxynew = [Gxynew, Gxy];
      Gxxnew = [Gxxnew, Gxx];
      Gyynew = [Gyynew, Gyy];
      Cohnew = [Cohnew, Coh];
      refDOFnew = [refDOFnew;refDOF];
      
   end
end

G = Gnew;
Gxy = Gxynew;
Gxx = Gxxnew;
Gxy = Gxynew;
Gyy = Gyynew;
Coh = Cohnew;
refDOF = refDOFnew;

%
%   Save the new DIAMOND data file with the multi-ref data
%

fprintf(1,'Saving Multiple reference Datafile...')

[filename,pathname,error] = savefile(0,pathname);

if error == 0,
   
   savedata
   
else
   
   disp('ERROR Saving Multi-reference Datafile!')
   
end

disp('Done Creating multi-reference Data file')