comparison 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
comparison
equal deleted inserted replaced
5923:611e30b984b3 5924:87fcda0eda04
35 ## Author: Daniel Calvelo <dcalvelo@yahoo.com> 35 ## Author: Daniel Calvelo <dcalvelo@yahoo.com>
36 ## Adapted-by: Paul Kienzle <pkienzle@kienzle.powernet.co.uk> 36 ## Adapted-by: Paul Kienzle <pkienzle@kienzle.powernet.co.uk>
37 37
38 function d = bin2dec (h) 38 function d = bin2dec (h)
39 39
40 if (nargin != 1) 40 if (nargin == 1 && ischar (h))
41 usage ("bin2dec (b)"); 41 n = rows (h);
42 d = zeros (n, 1);
43 for i = 1:n
44 s = h(i,:);
45 s = s(! isspace (s));
46 d(i) = base2dec (s, 2);
47 endfor
42 else 48 else
43 d = base2dec (h, 2); 49 print_usage ();
44 endif 50 endif
45 51
46 endfunction 52 endfunction