/[MITgcm]/MITgcm_contrib/enderton/Diagnostics/DiagUtility/tiles.m
ViewVC logotype

Annotation of /MITgcm_contrib/enderton/Diagnostics/DiagUtility/tiles.m

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


Revision 1.1 - (hide annotations) (download)
Mon Jan 31 15:43:29 2005 UTC (20 years, 5 months ago) by enderton
Branch: MAIN
CVS Tags: HEAD
 o Initial check in.

1 enderton 1.1 function [a] = tile(b,varargin)
2     % a=tile(b,n);
3     %
4     % Extract single tile from cubed array
5     %
6     % b can have dimensions (M*6,M,Nr) or (M,M,Nr,6)
7     %
8     % n can be vector of integers between 1 and 6
9    
10     if nargin==1
11     n=1:6;
12     else
13     n=varargin{1};
14     end
15    
16     if min(n)<1 | max(n)>6
17     disp(sprintf('n=',n));
18     error('tile: second argument n is out of range');
19     end
20    
21     if size(b,ndims(b))==6
22     switch ndims(b)
23     case 3,
24     a=b(:,:,n);
25     case 4,
26     a=b(:,:,:,n);
27     otherwise
28     error('tile: it seems that b has too many dimensions');
29     end
30     elseif size(b,2)==6
31     m=size(b,1);
32     k=1;
33     for N=n;
34     switch ndims(b)
35     case 3,
36     a(:,:,k)=squeeze(b(:,N,:));
37     case 4,
38     a(:,:,:,k)=squeeze(b(:,N,:,:));
39     otherwise
40     error('tile: it seems that b has too many dimensions');
41     end
42     k=k+1;
43     end
44     elseif size(b,1)==size(b,2)*6
45     m=size(b,2);
46     k=1;
47     for N=n;
48     switch ndims(b)
49     case 2,
50     a(:,:,k)=b((N-1)*m+1:N*m,:);
51     case 3,
52     a(:,:,:,k)=b((N-1)*m+1:N*m,:,:);
53     otherwise
54     error('tile: it seems that b has too many dimensions');
55     end
56     k=k+1;
57     end
58     else
59     disp(sprintf('Size(b) = %i %i %i %i %i %i',size(b)));
60     error('tile: Size of first argument is not consistent with cubed array');
61     end

  ViewVC Help
Powered by ViewVC 1.1.22