Home > classes > @ao > ao2m.m

ao2m

PURPOSE ^

AO2M converts an analysis object to an '.m' file based on the history

SYNOPSIS ^

function ao2m(a, filename)

DESCRIPTION ^

 AO2M converts an analysis object to an '.m' file based on the history
 contained in the analysis object.
 
 >> ao2m(a, 'filename');
 
 M Hewitson 08-02-07

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function ao2m(a, filename)
0002 
0003 % AO2M converts an analysis object to an '.m' file based on the history
0004 % contained in the analysis object.
0005 %
0006 % >> ao2m(a, 'filename');
0007 %
0008 % M Hewitson 08-02-07
0009 %
0010 
0011 ALGONAME = mfilename;
0012 VERSION  = '$Id: ao2m.html,v 1.1 2007/06/08 14:15:02 hewitson Exp $';
0013 
0014 if length(a) > 1
0015   error('### I can only deal with one AO at a time.');
0016 end
0017 
0018 % clear this m-file from memory
0019 clear(filename);
0020 
0021 % convert the history to a set of commands
0022 cmds = hist2m(a.hist);
0023 
0024 % Now write output file
0025 [path,name,ext,vers] = fileparts(filename);
0026 if isempty(ext)
0027   filename = [filename '.m'];
0028 end
0029 if ~strcmp(ext, '.m')
0030   error('### I can only write .m files.');
0031 end
0032 
0033 d = a.data;
0034 fd = fopen(filename, 'w+');
0035 fprintf(fd, '%% %s \n', upper(filename));
0036 fprintf(fd, '%% \n');
0037 fprintf(fd, '%% \n');
0038 fprintf(fd, '%% written by %s / %s\n', ALGONAME, VERSION);
0039 fprintf(fd, '%% \n');
0040 fprintf(fd, '%% based on analysis object:\n');
0041 fprintf(fd, '%%            name: %s / %s\n', a.name, d.name);
0042 fprintf(fd, '%%      provenance: %s\n', char(a.provenance));
0043 fprintf(fd, '%%         comment: %s\n', char(a.comment));
0044 fprintf(fd, '%% original m-file: %s\n', a.mfilename);
0045 fprintf(fd, '%% \n');
0046 fprintf(fd, '%% \n');
0047 fprintf(fd, ' \n');
0048 fprintf(fd, ' \n');
0049 for c=length(cmds):-1:1
0050   fprintf(fd, '%s\n', cmds{c});
0051 end
0052 fprintf(fd, ' \n');
0053 fprintf(fd, ' \n');
0054 fprintf(fd, '%% END\n');
0055 fclose(fd);

Generated on Fri 08-Jun-2007 16:09:11 by m2html © 2003