Mercurial > hg > octave-lyh
diff scripts/strings/dec2hex.m @ 13167:f7cb824dc8c0
Allow cellstr inputs for dec2* conversion functions.
* dec2base.m, dec2bin.m, dec2hex.m: Allow cellstr inputs.
Amend documentation for new feature and add test for new behavior.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Mon, 19 Sep 2011 18:03:43 -0700 |
parents | c792872f8942 |
children | 72c96de7a403 |
line wrap: on
line diff
--- a/scripts/strings/dec2hex.m +++ b/scripts/strings/dec2hex.m @@ -28,8 +28,9 @@ ## @end group ## @end example ## -## If @var{d} is a vector, return a string matrix, one row per value, -## padded with leading zeros to the width of the largest value. +## If @var{d} is a matrix or cell array, return a string matrix with one +## row per element in @var{d}, padded with leading zeros to the width of +## the largest value. ## ## The optional second argument, @var{len}, specifies the minimum ## number of digits in the result. @@ -51,8 +52,10 @@ endfunction -%!assert(strcmpi (dec2hex (2748), "abc")); -%!assert(strcmpi (dec2hex (2748, 5), "00abc")); + +%!assert(dec2hex (2748), "ABC"); +%!assert(dec2hex (2748, 5), "00ABC"); +%!assert(dec2hex ({2748, 2746}), ["ABC"; "ABA"]); %% Test input validation %!error dec2hex ();