Path: news.mathworks.com!not-for-mail
From: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Conversion of Columns into Decimals
Date: Sat, 8 Dec 2007 03:07:25 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 44
Message-ID: <fjd1pd$5mf$1@fred.mathworks.com>
References: <fjcsag$t98$1@fred.mathworks.com> <fjcu8k$mcp$1@fred.mathworks.com> <fjd062$fjd$1@fred.mathworks.com>
Reply-To: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1197083245 5839 172.30.248.37 (8 Dec 2007 03:07:25 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 8 Dec 2007 03:07:25 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:441519


"alan dinno" <alan_dinno@hotmail.com> wrote in message <fjd062$fjd
$1@fred.mathworks.com>...
> "Matt Fig" <spamanon@yahoo.com> wrote in message 
> <fjcu8k$mcp$1@fred.mathworks.com>...
> > "alan dinno" <alan_dinno@hotmail.com> wrote in message
> > <fjcsag$t98$1@fred.mathworks.com>...
> > > Hi - If matrix A contains only bits,I want a row 
> vector B 
> > > (with same length as size(A,2)) that contains the 
> > > conversion of each column in A into Decimal.
> > > 
> > > Example:
> > > 
> > >  A =[ 1 1 0 1 0
> > >       0 0 1 1 1
> > >       1 1 1 0 1
> > >       1 0 0 1 1 ]
> > > 
> > >  B=[bin2dec(A col 1),bin2dec(A col 2),bin2dec(A col 
> 3),...]
> > > 
> > > Thanks
> > > alan
> > 
> > 
> > B = bin2dec(num2str(A'))'
> 
> Matt - I used it on a big matrix and gave the error:
> 
> "??? Error using ==> bin2dec
> Binary string must be 52 bits or less."
> 
> Thanks
> alan
--------
  If vector B is to consist of double precison floating point numbers (double), 
these are capable of representing integers to only 53 bits of precision, since 
that is the number of bits in their significands.  The remaining bits of the 64 
are needed for sign and exponent.  If the columns of A are longer than that, 
your desired task is therefore impossible, in general, if you want exact 
representation, and presumably that is why 'bin2dec' complained.

Roger Stafford