help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem on bin2dec


From: Søren Hauberg
Subject: Re: problem on bin2dec
Date: Tue, 08 Aug 2006 19:14:05 +0200

Hi,
  This is an Octave bug! In octave bin2dec is implemented by calling
base2dec. In Matlab bin2dec ignores spaces, while base2dec doesn't. The
octave implementation of base2dec doesn't ignore spaces either (which is
correct).
  So the solution is to change bin2dec in octave. Perhaps it's enough to
add

  h = h(!isspace(h));

to bin2dec, but I the matlab documentation isn't very verbose, so I
don't know if this is enough. I think your problem will be solved by the
above fix.

Søren

tir, 08 08 2006 kl. 09:53 -0700, skrev frank wang:
> Hi, 
>  
> I have a matlab code that convert binary to decimal. For example,
>  
> a=num2str([ 1 1 1 0]);
> b=bin2dec(a); 
> ans=14.
>  
> However, on Octave,
>  
> bin2dec(num2str([1 1 1 0]))
> ans = 584.
>  
> How could I fix this? My data set is quite big.
>  
> Thanks
>  
> Frank
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www.cae.wisc.edu/mailman/listinfo/help-octave




reply via email to

[Prev in Thread] Current Thread [Next in Thread]