Mercurial > hg > octave-nkf
comparison 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 |
comparison
equal
deleted
inserted
replaced
13164:36afcd6fc45f | 13167:f7cb824dc8c0 |
---|---|
26 ## dec2hex (2748) | 26 ## dec2hex (2748) |
27 ## @result{} "ABC" | 27 ## @result{} "ABC" |
28 ## @end group | 28 ## @end group |
29 ## @end example | 29 ## @end example |
30 ## | 30 ## |
31 ## If @var{d} is a vector, return a string matrix, one row per value, | 31 ## If @var{d} is a matrix or cell array, return a string matrix with one |
32 ## padded with leading zeros to the width of the largest value. | 32 ## row per element in @var{d}, padded with leading zeros to the width of |
33 ## the largest value. | |
33 ## | 34 ## |
34 ## The optional second argument, @var{len}, specifies the minimum | 35 ## The optional second argument, @var{len}, specifies the minimum |
35 ## number of digits in the result. | 36 ## number of digits in the result. |
36 ## @seealso{hex2dec, dec2base, dec2bin} | 37 ## @seealso{hex2dec, dec2base, dec2bin} |
37 ## @end deftypefn | 38 ## @end deftypefn |
49 print_usage (); | 50 print_usage (); |
50 endif | 51 endif |
51 | 52 |
52 endfunction | 53 endfunction |
53 | 54 |
54 %!assert(strcmpi (dec2hex (2748), "abc")); | 55 |
55 %!assert(strcmpi (dec2hex (2748, 5), "00abc")); | 56 %!assert(dec2hex (2748), "ABC"); |
57 %!assert(dec2hex (2748, 5), "00ABC"); | |
58 %!assert(dec2hex ({2748, 2746}), ["ABC"; "ABA"]); | |
56 | 59 |
57 %% Test input validation | 60 %% Test input validation |
58 %!error dec2hex (); | 61 %!error dec2hex (); |
59 %!error dec2hex (1, 2, 3); | 62 %!error dec2hex (1, 2, 3); |
60 | 63 |