Mercurial > hg > ishara
view general/arrutils/revdims.m @ 13:03694e5c8365
Reorganised some high order list functions to correct class-based method dispatch; fixed some docs.
author | samer |
---|---|
date | Wed, 16 Jan 2013 12:12:34 +0000 |
parents | e44f49929e56 |
children |
line wrap: on
line source
function B=revdims(A,N) % revdims - reverse N dimensions of a multidimensional array % % revdims :: [[D:[[1,M]]]], N:natural -> [[D2:[[1,M]]]]. % revdims :: [[D:[[1,M]]]] -> [[D2:[[1,M]]]]. % % This takes an array of size [D(1:N) DX] % and returns an array of size [D(N:-1:1) DX] % where DX are the rest of the dimensions after the Nth and are % unaffected. N defaults to the number of dimensions disregarding % trailing singletons, ie numdims(A)==length(size1(A)) if nargin<2, N=numdims(A); end ND=max(N,2); DD=1:ND; DD(1:N)=fliplr(DD(1:N)); B=permute(A,DD);