0001 function atwritem(ring,filename)
0002
0003
0004
0005
0006
0007
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);
0024 fprintf(fid,'};\n');
0025
0026 if nargin>=2
0027 fprintf(fid,'end\n');
0028 fclose(fid);
0029 end
0030 end
0031