view general/fileutils/tofile.m @ 4:e44f49929e56

Adding reorganised general toolbox, now in several subdirectories.
author samer
date Sat, 12 Jan 2013 19:21:22 +0000
parents
children
line wrap: on
line source
function tofile(outfile,varargin)
% tofile - Run functions that need a file handle to write output
%
% tofile ::
%    path ~'file name to write to',
%    (fid -> action unit) ~'action taking file handle',
%    (fid -> action unit) ~'action taking file handle',
%    ...
% -> action unit.
%
%	Opens the given file in APPEND mode, then calls each function
%  passing the file handle to each. 


fh=fopen(outfile,'a');

fprintf(fh,'\n%% --- New session ---\n\n');

for i=1:length(varargin)
	fprintf(fh,'\n%% --- Running %s\n\n', func2str(varargin{i}));
	feval(varargin{i},fh);
end

fclose(fh);