changeset 5924:87fcda0eda04

[project @ 2006-08-14 18:41:15 by jwe]
author jwe
date Mon, 14 Aug 2006 18:41:15 +0000
parents 611e30b984b3
children fe5cedbf3806
files scripts/ChangeLog scripts/strings/bin2dec.m
diffstat 2 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,5 +1,7 @@
 2006-08-14  Søren Hauberg  <hauberg@gmail.com>
 
+	* strings/bin2dec.m: Ignore spaces in input for compatibility.
+
         * colormap.m: Change global variable to persistent.
 
 	* rgb2ind.m: Handle single 3-d array as rgb image.
--- a/scripts/strings/bin2dec.m
+++ b/scripts/strings/bin2dec.m
@@ -37,10 +37,16 @@
 
 function d = bin2dec (h)
 
-  if (nargin != 1)
-    usage ("bin2dec (b)");
+  if (nargin == 1 && ischar (h))
+    n = rows (h);
+    d = zeros (n, 1);
+    for i = 1:n
+      s = h(i,:);
+      s = s(! isspace (s));
+      d(i) = base2dec (s, 2);
+    endfor
   else
-    d = base2dec (h, 2);
+    print_usage ();
   endif
 
 endfunction