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).
RES = batchvec(..., 'nodisp') does not display the function call for
each file matching FILENAME in the command window.
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');
See Also
loadvec, loadarrayvec, loadset.