diff scripts/strings/dec2bin.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 fd0a3ac60b0e
children 72c96de7a403
line wrap: on
line diff
--- a/scripts/strings/dec2bin.m	Mon Sep 19 17:15:07 2011 -0700
+++ b/scripts/strings/dec2bin.m	Mon Sep 19 18:03:43 2011 -0700
@@ -28,8 +28,9 @@
 ## @end group
 ## @end example
 ##
-## If @var{d} is a vector, returns 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(strcmp (dec2bin (14), "1110"));
-%!assert(strcmp (dec2bin (14, 6), "001110"));
+
+%!assert(dec2bin (14), "1110");
+%!assert(dec2bin (14, 6), "001110");
+%!assert(dec2bin ({1, 2; 3, 4}), ["001"; "011"; "010"; "100"]);
 
 %%Test input validation
 %!error dec2bin ();