annotate toolboxes/MIRtoolbox1.3.2/MIRToolbox/@mirstruct/subsasgn.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function a = subsasgn(a,index,val)
wolffd@0 2 % SUBSASGN Define index assignment for mirstruct objects
wolffd@0 3 switch index(1).type
wolffd@0 4 case '.'
wolffd@0 5 if strcmpi(index(1).subs,'tmp')
wolffd@0 6 fields = a.fields;
wolffd@0 7 data = a.data;
wolffd@0 8
wolffd@0 9 if isa(val,'mirdata') || (iscell(val) && isa(val{1},'mirdata'))
wolffd@0 10 % If the 'tmp' data turns to be an actual evaluated data,
wolffd@0 11 % the mirstruct object is transformed into a simple struct.
wolffd@0 12 a = struct;
wolffd@0 13 for i = 1:length(fields)
wolffd@0 14 a.(fields{i}) = data{i};
wolffd@0 15 end
wolffd@0 16 a.tmp.(index(2).subs) = val;
wolffd@0 17 return
wolffd@0 18 end
wolffd@0 19
wolffd@0 20 if isa(val,'mirdesign')
wolffd@0 21 val = set(val,'Stored',{index.subs});
wolffd@0 22 end
wolffd@0 23 if length(index)>2
wolffd@0 24 if strcmpi(index(3).type,'{}')
wolffd@0 25 isubs = index(3).subs;
wolffd@0 26 if length(isubs)>1
wolffd@0 27 a.tmp.(index(2).subs){isubs{1},isubs{2}} = val;
wolffd@0 28 else
wolffd@0 29 a.tmp.(index(2).subs){isubs{1}} = val;
wolffd@0 30 end
wolffd@0 31 end
wolffd@0 32 else
wolffd@0 33 a.tmp.(index(2).subs) = val;
wolffd@0 34 end
wolffd@0 35 aa = struct;
wolffd@0 36 aa.fields = fields;
wolffd@0 37 aa.data = data;
wolffd@0 38 aa.tmp = a.tmp;
wolffd@0 39 aa.stat = a.stat;
wolffd@0 40 a = class(aa,'mirstruct',val);
wolffd@0 41 return
wolffd@0 42 end
wolffd@0 43 [is,id] = ismember(index(1).subs,a.fields);
wolffd@0 44 if not(is)
wolffd@0 45 a.fields{end+1} = index(1).subs;
wolffd@0 46 a.data{end+1} = [];
wolffd@0 47 id = length(a.fields);
wolffd@0 48 end
wolffd@0 49 if length(index) == 1
wolffd@0 50 a.data{id} = val;
wolffd@0 51 else
wolffd@0 52 a.data{id} = subsasgn(a.data{id},index(2:end),val);
wolffd@0 53 end
wolffd@0 54 if get(val,'NoChunk') && isframed(a)
wolffd@0 55 a = set(a,'FrameDontChunk',1);
wolffd@0 56 % Frame-decomposed flowchart where one dependent variable requires
wolffd@0 57 % a complete computation. Should not therefore be evaluated
wolffd@0 58 % chunk after chunk.
wolffd@0 59 end
wolffd@0 60 end