samer@4: function tofile(outfile,varargin) samer@4: % tofile - Run functions that need a file handle to write output samer@4: % samer@4: % tofile :: samer@4: % path ~'file name to write to', samer@4: % (fid -> action unit) ~'action taking file handle', samer@4: % (fid -> action unit) ~'action taking file handle', samer@4: % ... samer@4: % -> action unit. samer@4: % samer@4: % Opens the given file in APPEND mode, then calls each function samer@4: % passing the file handle to each. samer@4: samer@4: samer@4: fh=fopen(outfile,'a'); samer@4: samer@4: fprintf(fh,'\n%% --- New session ---\n\n'); samer@4: samer@4: for i=1:length(varargin) samer@4: fprintf(fh,'\n%% --- Running %s\n\n', func2str(varargin{i})); samer@4: feval(varargin{i},fh); samer@4: end samer@4: samer@4: fclose(fh);