# HG changeset patch # User Rik # Date 1276093773 25200 # Node ID b32a0214a464c45856aba854d2d268ce196f3f16 # Parent e0ba186b242b56b03387c096de4a1ce5dd1624ac Use > 1 test to find first non-singleton dimension rather than != 1. diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,20 +1,26 @@ -2010-06-03 Rik +2010-06-09 Rik + + * general/flipdim.m, general/accumdim.m: Use > 1 test to find + first non-singleton dimension rather than != 1. + +2010-06-08 Rik * general/cumtrapz.m, general/postpad.m, general/prepad.m, general/shift.m, general/trapz.m, signal/unwrap.m: Use common method to find first non-singleton dimension. -2010-06-03 Rik + +2010-06-08 Rik * general/rotdim.m: Modify function to use same variable names as documentation. -2010-06-03 Rik +2010-06-08 Rik * general/cart2pol.m, general/cart2sph.m, general/pol2cart.m, general/sph2cart.m: Add option to operate on column matrix of coordinates. -2010-06-03 Rik +2010-06-08 Rik * general/arrayfun.m, general/cart2pol.m, general/cart2sph.m, general/idivide.m, general/logspace.m, general/sph2cart.m, diff --git a/scripts/general/accumdim.m b/scripts/general/accumdim.m --- a/scripts/general/accumdim.m +++ b/scripts/general/accumdim.m @@ -17,7 +17,7 @@ ## . ## -*- texinfo -*- -## @deftypefn {Function File} {} accumdim (@var{subs}, @var{vals}, @var{dim}, @var{sz}, @var{func}, @var{fillval}) +## @deftypefn {Function File} {} accumdim (@var{subs}, @var{vals}, @var{dim}, @var{n}, @var{func}, @var{fillval}) ## Create an array by accumulating the slices of an array into the ## positions defined by their subscripts along a specified dimension. ## The subscripts are defined by the index vector @var{subs}. @@ -63,7 +63,7 @@ endif if (! isvector (subs)) - error ("accumdim: subs must be a subscript vector"); + error ("accumdim: SUBS must be a subscript vector"); elseif (! isindex (subs)) # creates index cache error ("accumdim: indices must be positive integers"); else @@ -71,16 +71,16 @@ if (n == 0) n = m; elseif (n < m) - error ("accumdim: index out of range") + error ("accumdim: N index out of range") endif endif sz = size (val); if (nargin < 3) - [~, dim] = max (sz != 1); # first non-singleton dim + [~, dim] = max (sz > 1); # first non-singleton dim elseif (! isindex (dim)) - error ("accumdim: dim must be a valid dimension"); + error ("accumdim: DIM must be a valid dimension"); elseif (dim > length (sz)) sz(end+1:dim) = 1; endif diff --git a/scripts/general/flipdim.m b/scripts/general/flipdim.m --- a/scripts/general/flipdim.m +++ b/scripts/general/flipdim.m @@ -18,9 +18,11 @@ ## . ## -*- texinfo -*- -## @deftypefn {Function File} {} flipdim (@var{x}, @var{dim}) +## @deftypefn {Function File} {} flipdim (@var{x}) +## @deftypefnx {Function File} {} flipdim (@var{x}, @var{dim}) ## Return a copy of @var{x} flipped about the dimension @var{dim}. -## For example +## @var{dim} defaults to the first non-singleton dimension. +## For example, ## ## @example ## @group @@ -43,13 +45,13 @@ nd = ndims (x); if (nargin == 1) ## Find the first non-singleton dimension. - dim = find (size (x) != 1, 1); + dim = find (size (x) > 1, 1); if (isempty (dim)) dim = 1; endif else if (! (isscalar (dim) && isindex (dim, nd))) - error ("flipdim: dim must be an integer and valid dimension"); + error ("flipdim: DIM must be an integer and a valid dimension"); endif endif