batchvec.mBack to Contents<< Prev |  Next >> 

batchvec
Execute a function for a series of files

Description
RES = batchvec(FILENAME,FUN) executes the function FUN for each file 
matching FILENAME. Wildcards (*) and brackets ([]) may be used (see 
expandstr). This is formally equivalent to calling the function FUN 
with the argument loadvec(FILENAME), except that the fields are not 
stored in a structure array, but sent one by one to the function FUN. 
This is useful for handling a large number of files which cannot be 
stored into a structure array for lack of memory. All the file formats 
supported by loadvec are also supported by batchvec. The result RES is 
an array whose elements are the output of the function FUN applied to 
each file matching FILENAME. 
 
RES = batchvec(FILENAME,FUN,ARG) also passes the argument(s) ARG to 
the function FUN. This is formally equivalent as FUN(loadvec(...),ARG) 
(this works only for simple arguments, as strings and numbers, not for 
arrays and cell arrays). 
 
Examples: 
 
   st=batchvec('set*/B00001.VEC','statf') calls the function statf for 
   each file B00001.VEC in each directory matching 'set*'. 
 
   batchvec('set*/B*.VEC','showvec','rot',8) is equivalent to 
   showvec(loadvec('set*/B*.VEC'),'rot',8), except that the files are 
   not stored in a structure array. 
 
If the function FUN to be executed is more complex, you may create a 
M-File called 'myfunction.m', that contains the complex computation to 
be executed for each field V, and to execute RES = 
batchvec(FILENAME,'myfunction'). 
 
Example: Create the following M-File called 'enstrophy.m': 
     function z=enstrophy(v), 
     stat=statf(vec2scal(filterf(v,1),'rot')); 
     z=stat.rms^2; 
Then call:  z=batchvec('set*/*.vec','enstrophy'); 
 
F. Moisy 
Revision: 1.00,  Date: 2005/10/29. 
 
See Also
loadvec, loadarrayvec, loadset. 

 Previous: averfNext: bwfilterf 

Help file generated by m2html 1.06