/[MITgcm]/MITgcm_contrib/gael/matlab_class/@gcmfaces/subsasgn.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/matlab_class/@gcmfaces/subsasgn.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Wed Feb 10 14:43:48 2010 UTC (15 years, 5 months ago) by gforget
Branch: MAIN
matlab_class core routine: gcmfaces methods

1 gforget 1.1 function a = subsasgn(a,index,val)
2    
3     switch index(1).type
4     case '{}'
5     if length(index)>1;
6     aa=subsref(a,index(1)); val=subsasgn(aa,index(2:end),val);
7     end;
8    
9     nFaces=get(a,'nFaces');
10     iFace=index(1).subs{:};
11     if iFace<=nFaces&iFace>0;
12     eval(['a.f' num2str(iFace) '=val;']);
13     else
14     error('Index out of range')
15     end
16     case '.'
17     if length(index)>1;
18     aa=subsref(a,index(1)); val=subsasgn(aa,index(2:end),val);
19     end;
20    
21     a=set(a,index(1).subs,val);
22     case '()'
23     if length(index)>1; error('indexing not supported by gcmfaces objects'); end;
24    
25     for iFace=1:a.nFaces; iF=num2str(iFace);
26     if isa(index.subs{1},'gcmfaces');
27     if isa(val,'gcmfaces');
28     eval(['a.f' iF '(index.subs{1}.f' iF ')=val.f' iF ';']);
29     else;
30     eval(['a.f' iF '(index.subs{1}.f' iF ')=val;']);
31     end;
32     else;
33     if isa(val,'gcmfaces');
34     eval(['a.f' iF '=subsasgn(a.f' iF ',index,val.f' iF ');']);
35     else;
36     eval(['a.f' iF '=subsasgn(a.f' iF ',index,val);']);
37     end;
38     end;
39     end;
40     otherwise
41     error('indexing not supported by gcmfaces objects')
42     end
43    
44     %if length(index)>1; b=subsref(b,index(2:end)); end;
45    

  ViewVC Help
Powered by ViewVC 1.1.22