comparison scripts/general/rotdim.m @ 5018:1c65a8e44ef9 ss-2-1-59

[project @ 2004-09-22 03:33:29 by jwe]
author jwe
date Wed, 22 Sep 2004 03:33:29 +0000
parents ed25bed43409
children c08cb1098afc
comparison
equal deleted inserted replaced
5017:35403c316afd 5018:1c65a8e44ef9
58 58
59 if (nargin < 1 || nargin > 3) 59 if (nargin < 1 || nargin > 3)
60 usage ("rotdim (x, k, plane)"); 60 usage ("rotdim (x, k, plane)");
61 endif 61 endif
62 62
63 if (nargin > 1 && !isempty(k)) 63 if (nargin > 1 && ! isempty(k))
64 if (imag (k) != 0 || fix (k) != k) 64 if (imag (k) != 0 || fix (k) != k)
65 error ("rotdim: k must be an integer"); 65 error ("rotdim: k must be an integer");
66 endif 66 endif
67 else 67 else
68 k = 1; 68 k = 1;
101 k = k + 4; 101 k = k + 4;
102 endif 102 endif
103 if (k == 0) 103 if (k == 0)
104 y = x; 104 y = x;
105 elseif (k == 2) 105 elseif (k == 2)
106 y = flipdim (flipdim (x, plane (1)), plane (2)); 106 y = flipdim (flipdim (x, plane(1)), plane(2));
107 elseif (k == 1 || k == 3) 107 elseif (k == 1 || k == 3)
108 perm = 1:nd; 108 perm = 1:nd;
109 perm(plane(1)) = plane(2); 109 perm(plane(1)) = plane(2);
110 perm(plane(2)) = plane(1); 110 perm(plane(2)) = plane(1);
111 y = permute (x, perm); 111 y = permute (x, perm);