/[MITgcm]/MITgcm/utils/matlab/tiles.m
ViewVC logotype

Contents of /MITgcm/utils/matlab/tiles.m

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


Revision 1.2 - (show annotations) (download)
Fri Jun 4 17:03:50 2004 UTC (19 years, 11 months ago) by adcroft
Branch: MAIN
CVS Tags: checkpoint53f_post, checkpoint54a_pre, checkpoint55c_post, checkpoint57m_post, checkpoint57h_done, checkpoint57g_pre, checkpoint57f_post, checkpoint57j_post, checkpoint57b_post, checkpoint53d_post, checkpoint57f_pre, checkpoint55d_pre, checkpoint57g_post, checkpoint57a_post, checkpoint55j_post, checkpoint56b_post, checkpoint57h_pre, checkpoint54a_post, checkpoint55h_post, checkpoint54b_post, checkpoint57e_post, checkpoint54d_post, checkpoint56c_post, checkpoint54e_post, checkpoint55b_post, checkpoint55, checkpoint55a_post, checkpoint57c_pre, checkpoint57o_post, checkpoint55g_post, checkpoint57r_post, checkpoint57k_post, checkpoint57d_post, checkpoint55f_post, checkpoint57i_post, checkpoint57h_post, checkpoint57a_pre, checkpoint54, checkpoint57, checkpoint56, checkpoint53g_post, checkpoint57n_post, checkpoint57p_post, checkpoint57q_post, checkpoint54f_post, eckpoint57e_pre, checkpoint57c_post, checkpoint55e_post, checkpoint54c_post, checkpoint55i_post, checkpoint57l_post, checkpoint56a_post, checkpoint55d_post
Changes since 1.1: +6 -1 lines
New scripts and M6.5 compatibility issues

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