Thread Subject: reinterpret double as fix point

Subject: reinterpret double as fix point

From: Stefan Jakobs

Date: 30 Oct, 2009 11:38:07

Message: 1 of 2

Hello,

I'm converting a double value to a fix point value and then pass that value to a mex file. The return type of the mex file is double, but the actual value is of type fix point.
So, how can I make matlab to recognise the double value as a fix point value?

example (fix_point is the mex file):

a = fix_point(fi(-1.5, true, 4, 2))
class(a)
      ans = double
a
      ans = 2.1220e-314

But that is the wrong value, because 'a' should be interpreted as type fi.

Thanks for your help.
Greetings
Stefan

Subject: reinterpret double as fix point

From: Tom Bryan

Date: 30 Oct, 2009 12:43:26

Message: 2 of 2

Hello Stefan,

There is no public interface for the fi object in hand-written mex files.

However, you can compile a MATLAB function into a mex function with fi
inputs and outputs using emlmex.

If you want to use handwritten mex files, then use builtin integer
inputs and outputs, and cast to and from fi objects outside of the mex
function.

Let me know if you need more details.

Best wishes,
Tom Bryan
tom.bryan@mathworks.com

Stefan Jakobs wrote:
> Hello,
>
> I'm converting a double value to a fix point value and then pass that value to a mex file. The return type of the mex file is double, but the actual value is of type fix point.
> So, how can I make matlab to recognise the double value as a fix point value?
>
> example (fix_point is the mex file):
>
> a = fix_point(fi(-1.5, true, 4, 2))
> class(a)
> ans = double
> a
> ans = 2.1220e-314
>
> But that is the wrong value, because 'a' should be interpreted as type fi.
>
> Thanks for your help.
> Greetings
> Stefan

Tags for this Thread

Everyone's Tags:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
reinterpret Stefan Jakobs 30 Oct, 2009 07:39:06
fi Stefan Jakobs 30 Oct, 2009 07:39:05
rssFeed for this Thread

Contact us at files@mathworks.com