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

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