Thread Subject: How to know the real value of a binary data in fi type

Subject: How to know the real value of a binary data in fi type

From: fl

Date: 26 Jun, 2009 15:47:22

Message: 1 of 4

Hi,
I have a defined numerical type, for example, T = numerictype(true,
10, 9);
I get a binary number: 0010110101.
I want to get the real value of the binary number interpreted by
numerical type T. I don't find any function in fixed point for my
question. Could you tell me that? Thanks.

Subject: How to know the real value of a binary data in fi type

From: Nathan

Date: 26 Jun, 2009 15:50:01

Message: 2 of 4

On Jun 26, 8:47 am, fl <rxjw...@gmail.com> wrote:
> Hi,
> I have a defined numerical type, for example, T = numerictype(true,
> 10, 9);
> I get a binary number: 0010110101.
> I want to get the real value of the binary number interpreted by
> numerical type T. I don't find any function in fixed point for my
> question. Could you tell me that? Thanks.

Do you mean you want the decimal (base 10) value for your binary
number?
If so: doc bin2dec

Hope that helps.
-Nathan

Subject: How to know the real value of a binary data in fi type

From: fl

Date: 26 Jun, 2009 15:58:12

Message: 3 of 4

On Jun 26, 11:50 am, Nathan <ngrec...@gmail.com> wrote:
> On Jun 26, 8:47 am, fl <rxjw...@gmail.com> wrote:
>
> > Hi,
> > I have a defined numerical type, for example, T = numerictype(true,
> > 10, 9);
> > I get a binary number: 0010110101.
> > I want to get the real value of the binary number interpreted by
> > numerical type T. I don't find any function in fixed point for my
> > question. Could you tell me that? Thanks.
>
> Do you mean you want the decimal (base 10) value for your binary
> number?
> If so: doc bin2dec
>
> Hope that helps.
> -Nathan

Thank.
According to the numerical type definition of fixed point toolbox, the
data has a fraction. It is not an integer.

Subject: How to know the real value of a binary data in fi type

From: Ashok Charry

Date: 26 Jun, 2009 17:29:30

Message: 4 of 4

Hi fl,

This is what you probably want:

T = numerictype(true,10, 9);
a = fi(0,T,'bin','0010110101')

a =

     0.3535

           DataTypeMode: Fixed-point: binary point scaling
             Signedness: Signed
             WordLength: 10
         FractionLength: 9

Now at any time you can do:
a.bin = newbinnvalue; % where newbinvalue is a binary string

Hope this helps,

Ashok Charry
The MathWorks.


fl wrote:
> On Jun 26, 11:50 am, Nathan <ngrec...@gmail.com> wrote:
>> On Jun 26, 8:47 am, fl <rxjw...@gmail.com> wrote:
>>
>>> Hi,
>>> I have a defined numerical type, for example, T = numerictype(true,
>>> 10, 9);
>>> I get a binary number: 0010110101.
>>> I want to get the real value of the binary number interpreted by
>>> numerical type T. I don't find any function in fixed point for my
>>> question. Could you tell me that? Thanks.
>> Do you mean you want the decimal (base 10) value for your binary
>> number?
>> If so: doc bin2dec
>>
>> Hope that helps.
>> -Nathan
>
> Thank.
> According to the numerical type definition of fixed point toolbox, the
> data has a fraction. It is not an integer.

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com