1 |
function b = subsref(a,index) |
2 |
%overloaded gcmfaces subsref function : subscripted reference 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 |
|
7 |
switch index(1).type |
8 |
case '{}' |
9 |
nFaces=get(a,'nFaces'); |
10 |
iFace=index(1).subs{:}; |
11 |
if iFace<=nFaces&iFace>0; |
12 |
eval(['b=a.f' num2str(iFace) ';']); |
13 |
else |
14 |
error('Index out of range') |
15 |
end |
16 |
|
17 |
if length(index)>1; b=subsref(b,index(2:end)); end; |
18 |
case '.' |
19 |
b = get(a,index(1).subs); |
20 |
|
21 |
if length(index)>1; b=subsref(b,index(2:end)); end; |
22 |
case '()' |
23 |
if length(index)>1; error('indexing not supported by gcmfaces objects'); end; |
24 |
|
25 |
b=a; |
26 |
for iFace=1:a.nFaces; iF=num2str(iFace); |
27 |
if isa(index.subs{1},'gcmfaces'); |
28 |
eval(['b.f' iF '=a.f' iF '(index.subs{1}.f' iF ');']); |
29 |
else; |
30 |
eval(['b.f' iF '=subsref(a.f' iF ',index);']); |
31 |
end; |
32 |
end; |
33 |
otherwise |
34 |
error('indexing not supported by gcmfaces objects') |
35 |
end |
36 |
|
37 |
|