Home > analyzePRF > utilities > consolidatematdir.m

consolidatematdir

PURPOSE ^

function f = consolidatematdir(dir0,varsexclude)

SYNOPSIS ^

function f = consolidatematdir(dir0,varsexclude)

DESCRIPTION ^

 function f = consolidatematdir(dir0,varsexclude)

 <dir0> is a path to a directory
 <varsexclude> (optional) is a variable name or a cell vector of
   variable names to NOT load.  if [] or not supplied, load everything.

 use consolidatemat.m to load all *.mat files
 in <dir0> and write the results to <dir0>.mat.
 return a string that refers to the location of the written file.

 example:
 mkdir('test');
 a = 1; b = 2; save('test/001.mat','a','b');
 a = 3; b = 4; save('test/002.mat','a','b');
 consolidatematdir('test');
 results = loadmulti('test.mat','results');
 results(1)
 results(2)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function f = consolidatematdir(dir0,varsexclude)
0002 
0003 % function f = consolidatematdir(dir0,varsexclude)
0004 %
0005 % <dir0> is a path to a directory
0006 % <varsexclude> (optional) is a variable name or a cell vector of
0007 %   variable names to NOT load.  if [] or not supplied, load everything.
0008 %
0009 % use consolidatemat.m to load all *.mat files
0010 % in <dir0> and write the results to <dir0>.mat.
0011 % return a string that refers to the location of the written file.
0012 %
0013 % example:
0014 % mkdir('test');
0015 % a = 1; b = 2; save('test/001.mat','a','b');
0016 % a = 3; b = 4; save('test/002.mat','a','b');
0017 % consolidatematdir('test');
0018 % results = loadmulti('test.mat','results');
0019 % results(1)
0020 % results(2)
0021 
0022 % input
0023 if ~exist('varsexclude','var') || isempty(varsexclude)
0024   varsexclude = [];
0025 end
0026 
0027 % do it
0028 dir0 = matchfiles(dir0);
0029 dir0 = dir0{1};
0030 [f,file0] = stripfile(dir0);
0031 if isempty(f)  % VOODOO.  BE CAREFUL.
0032   pre0 = '';
0033 else
0034   pre0 = [f '/'];
0035 end
0036 consolidatemat([pre0 file0 '/*.mat'],[pre0 file0 '.mat'],varsexclude);
0037 f = [pre0 file0 '.mat'];

Generated on Wed 18-Jun-2014 21:47:41 by m2html © 2005