/[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.2 - (hide annotations) (download)
Thu Oct 20 20:57:02 2011 UTC (13 years, 8 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65x, checkpoint65r, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, HEAD
Changes since 1.1: +4 -0 lines
- add help sections at the top.

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

  ViewVC Help
Powered by ViewVC 1.1.22