diff scripts/strings/bin2dec.m @ 5924:87fcda0eda04

[project @ 2006-08-14 18:41:15 by jwe]
author jwe
date Mon, 14 Aug 2006 18:41:15 +0000
parents 4a48a1df26b7
children 93c65f2a5668
line wrap: on
line diff
--- a/scripts/strings/bin2dec.m	Mon Aug 14 18:29:18 2006 +0000
+++ b/scripts/strings/bin2dec.m	Mon Aug 14 18:41:15 2006 +0000
@@ -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