Home > classes > @ao > ao2m.m

ao2m

PURPOSE ^

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

SYNOPSIS ^

function ao2m(a, filename)

DESCRIPTION ^

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

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: AO2M converts an analysis object to an '.m' file based on the
              history contained in the analysis object.

 CALL:        ao2m(a, 'filename');

 VERSION:     $Id: ao2m.m,v 1.9 2007/06/25 14:06:29 ingo Exp $

 HISTORY: 08-02-07 M Hewitson
             Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

Generated on Mon 03-Sep-2007 12:12:34 by m2html © 2003