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
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com