Daniel@0: function a = subsasgn(a,index,val) Daniel@0: % SUBSASGN Define index assignment for mirstruct objects Daniel@0: switch index(1).type Daniel@0: case '.' Daniel@0: if strcmpi(index(1).subs,'tmp') Daniel@0: fields = a.fields; Daniel@0: data = a.data; Daniel@0: Daniel@0: if isa(val,'mirdata') || (iscell(val) && isa(val{1},'mirdata')) Daniel@0: % If the 'tmp' data turns to be an actual evaluated data, Daniel@0: % the mirstruct object is transformed into a simple struct. Daniel@0: a = struct; Daniel@0: for i = 1:length(fields) Daniel@0: a.(fields{i}) = data{i}; Daniel@0: end Daniel@0: a.tmp.(index(2).subs) = val; Daniel@0: return Daniel@0: end Daniel@0: Daniel@0: if isa(val,'mirdesign') Daniel@0: val = set(val,'Stored',{index.subs}); Daniel@0: end Daniel@0: if length(index)>2 Daniel@0: if strcmpi(index(3).type,'{}') Daniel@0: isubs = index(3).subs; Daniel@0: if length(isubs)>1 Daniel@0: a.tmp.(index(2).subs){isubs{1},isubs{2}} = val; Daniel@0: else Daniel@0: a.tmp.(index(2).subs){isubs{1}} = val; Daniel@0: end Daniel@0: end Daniel@0: else Daniel@0: a.tmp.(index(2).subs) = val; Daniel@0: end Daniel@0: aa = struct; Daniel@0: aa.fields = fields; Daniel@0: aa.data = data; Daniel@0: aa.tmp = a.tmp; Daniel@0: aa.stat = a.stat; Daniel@0: a = class(aa,'mirstruct',val); Daniel@0: return Daniel@0: end Daniel@0: [is,id] = ismember(index(1).subs,a.fields); Daniel@0: if not(is) Daniel@0: a.fields{end+1} = index(1).subs; Daniel@0: a.data{end+1} = []; Daniel@0: id = length(a.fields); Daniel@0: end Daniel@0: if length(index) == 1 Daniel@0: a.data{id} = val; Daniel@0: else Daniel@0: a.data{id} = subsasgn(a.data{id},index(2:end),val); Daniel@0: end Daniel@0: if get(val,'NoChunk') && isframed(a) Daniel@0: a = set(a,'FrameDontChunk',1); Daniel@0: % Frame-decomposed flowchart where one dependent variable requires Daniel@0: % a complete computation. Should not therefore be evaluated Daniel@0: % chunk after chunk. Daniel@0: end Daniel@0: end