[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bin2dec behavior different from Matlab?
From: |
Miguel Bazdresch |
Subject: |
bin2dec behavior different from Matlab? |
Date: |
Thu, 15 Mar 2012 21:57:14 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:10.0.2) Gecko/20120217 Thunderbird/10.0.2 |
Hello,
In my teaching I encourage students to use Octave, but some of them
cling to Matlab. Today we found different behavior between the two:
In Octave, both 3.4 and 3.6,
> s=num2str([1 0 1])
s = 1 0 1
> bin2dec(s)
ans = 257
In Matlab (version 2009), the same commands result in number 5.
I believe Octave is interpreting the spaces in 's' as zeros, which
explain the answer of 257. In any case, this difference in behavior is
something we may want to address. Personally, I find Matlab's behavior
to be more reasonable and useful in this particular case.
Best regards,
--
Miguel Bazdresch
- bin2dec behavior different from Matlab?,
Miguel Bazdresch <=
- Re: bin2dec behavior different from Matlab?, Daniel J Sebald, 2012/03/16
- Re: bin2dec behavior different from Matlab?, Rik, 2012/03/16
- Re: bin2dec behavior different from Matlab?, John W. Eaton, 2012/03/16
- Re: bin2dec behavior different from Matlab?, Rik, 2012/03/16
- Re: bin2dec behavior different from Matlab?, Daniel J Sebald, 2012/03/16