Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Tom

Posts: 2
Registered: 3/14/05
Re: convert matrix elements from decimal to binary
Posted: Aug 6, 2013 5:08 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.