Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: convert matrix elements from decimal to binary
Replies: 2   Last Post: Aug 6, 2013 5:08 AM

 Tom Posts: 2 Registered: 3/14/05
Re: convert matrix elements from decimal to binary
Posted: Aug 6, 2013 5:08 AM

Lars Gregersen <larsg @ comsol . dk> wrote in message <460gbvkf2v9o5vlfjuniffjvt0j3smsjpq@4ax.com>...
> On 5 May 2003 06:55:46 -0700, keithsullivan31@hotmail.com (Keith
> Sullivan) wrote:
>

> >I want to convert a matrix of decimals to a matrix of binary numbers.
> >
> >For example, if M = [ 1 3
> > 6 9 ]
> >
> >I then want, M = [ 0001 0011
> > 0110 1001 ]
> >
> >If I use dec2bin(M), I get a string of all the elements, not each
> >element converted to binary. Any help/pointers would be appreciated.

>
> I'm not sure what you are trying to do. Perhaps this will help?
>
> a = dec2bin(M,4)
> b = reshape(cellstr(a), 2, 2)
>
>
> Lars
>
> Lars Gregersen
> COMSOL A/S
> http://www.comsol.dk

HAI..
Thank you for your help..i created the matrix using the above code.How to access each element in the matrix bitwise??
if i am giving b(2,1) i am getting binary of 6.but how to take individual bits from that word??i want to compare each bit with another value