function n=numdims(x)
% numdims - Dimension of multidimensional array
%
% numdims :: [Size] -> natural.
%
% n=numdims(x), where n=length(size1(x)), ie not counting any
% trailing singleton dimensions. Eg
%    numdims(1)=0
%    numdims([1;2;3])=1
%    numdims([1 2 3])=2

sz=size(x);
n=length(sz);
while n>0 && sz(n)==1, n=n-1; end;
