help-octave
[Top][All Lists]
Advanced

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

Re: problem on bin2dec


From: Miroslaw Kwasniak
Subject: Re: problem on bin2dec
Date: Tue, 8 Aug 2006 20:11:56 +0200
User-agent: Mutt/1.5.9i

On Tue, Aug 08, 2006 at 09:53:03AM -0700, frank wang wrote:
> 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.

It depends on octave version, my gives
octave:1> bin2dec(num2str([1 1 1 0]))
ans = 8594130944
;)

Octave doesn't ignore spaces given by num2str.

My solution for this problem is:

octave:4> bin2dec(sprintf('%d',[1 1 1 0]))
ans = 14

Mirek


reply via email to

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