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