Home > lattice > atwritem.m

atwritem

PURPOSE ^

ATWRITEM Creates a .m file to store an AT structure

SYNOPSIS ^

function atwritem(ring,filename)

DESCRIPTION ^

ATWRITEM Creates a .m file to store an AT structure

ATWRITEM(RING)
   Prints the result in the command window
ATWRITEM(RING,FILENAME)
   Prints the result in a file

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function atwritem(ring,filename)
0002 %ATWRITEM Creates a .m file to store an AT structure
0003 %
0004 %ATWRITEM(RING)
0005 %   Prints the result in the command window
0006 %ATWRITEM(RING,FILENAME)
0007 %   Prints the result in a file
0008 
0009 if nargin>=2
0010     [pname,fname,ext]=fileparts(filename);
0011     if isempty(ext), ext='.m'; end
0012     fn=fullfile(pname,[fname ext]);
0013     [fid,mess]=fopen(fullfile(pname,[fname ext]),'wt');
0014     if fid==-1
0015         error('AT:FileErr','Cannot Create file %s\n%s',fn,mess);
0016     end
0017     fprintf(fid,'function ring=%s()\n',fname);
0018 else
0019     fid=1;
0020 end
0021 
0022 fprintf(fid,'ring={...\n');
0023 ok=cellfun(@(elem) fprintf(fid,'%s;...\n',at2str(elem)),ring); %#ok<NASGU>
0024 fprintf(fid,'};\n');
0025 
0026 if nargin>=2
0027     fprintf(fid,'end\n');
0028     fclose(fid);
0029 end
0030 end
0031

Generated on Thu 24-Aug-2017 18:47:33 by m2html © 2005