subsasgn

PURPOSE ^

SUBSASGN - handle indexed assignments to objects

SYNOPSIS ^

function md = subsasgn(md,index,val)

DESCRIPTION ^

SUBSASGN - handle indexed assignments to objects

   the first argument is the object, the second argument a structure array
   the third one is the value

   Usage:
      md = subsasgn(md,index,val)

   See also SUBSREF

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function md = subsasgn(md,index,val)
0002 %SUBSASGN - handle indexed assignments to objects
0003 %
0004 %   the first argument is the object, the second argument a structure array
0005 %   the third one is the value
0006 %
0007 %   Usage:
0008 %      md = subsasgn(md,index,val)
0009 %
0010 %   See also SUBSREF
0011 
0012 if ~isempty(md.repository),
0013     field=index(1).subs;
0014     if exist(['.' md.repository '.' field],'file'),
0015         if length(index)==1,
0016             %save val in corresponding repository
0017             eval([field '=val;']);
0018             eval(['save .' md.repository '.' field ' ' field]);
0019         else
0020             %load field from file
0021             load(['.' md.repository '.' field],'-mat');
0022             fieldval=eval(field);
0023             eval([field '=builtin(''subsasgn'',fieldval,index(2),val);']);
0024             eval(['save .' md.repository '.' field ' ' field]);
0025         end
0026     else
0027         md=builtin('subsasgn',md,index,val);
0028     end
0029 else
0030     md=builtin('subsasgn',md,index,val);
0031 end

Generated on Sun 29-Mar-2009 20:22:55 by m2html © 2003