Re: Call a MEX function from Matlab Engine?



"David Doria" <daviddoria@xxxxxxxxx> wrote in message
<frh3ul$qi1$1@xxxxxxxxxxxxxxxxxx>...
Sorry I was not clear. The actual c++ function I want to
minimze is

double CostFunction();

I don't get it. What is the independent variable here? Cost
function based on what independent input(s)? How were you
thinking of calling fminunc or fmincon?

CostFunction() calls many other functions such as
DistanceToPoint(), DistanceToPolygon() blah blah and also
records alot of things that are globals for the sake of the
OpenGL portion of my program. Also, these Distance()
functions that I mention rely on alot of classes that I
wrote such as
class Polygon
class Edge
etc

I don't see how I can mex call of those things. Maybe I
simply can't do this.

Compiling is not the issue, really. You can use all of your
classes and custom functions in a mex routine. Think of it
this way: A mex routine is a dll with no console i/o
capability that hooks directly into MATLAB as a callable
function, whereas an engine application is a stand-alone
program with full console i/o capability that communicates
with a separate MATLAB process via (I think) a COM link. But
in both cases you still have full access to everything that
a C++ compiler can compile.

Sounds like you need your mex routine to communicate data
with your engine application (i.e., the globals you mention
and maybe other things). Is this correct? If so, then that
is going to be a problem. We can probably set up something
to transmit fundamental types back & forth (int, double,
etc.), but if you need to transmit class variables back &
forth then that would be a huge issue and probably not worth
the effort.

I found a package called GSL (GNU
scientific library) that has some unconstrained
minimization, and also a package for GSL called OOL (Open
Optimization Library) that contains some basic constrained
minimization functions. These seem to work fine, but I
would have like to confirm their results with the matlab
fminunc() and fmincon() functions.

If you can set your problem up so that your cost function
fits into something fminunc and fmincon can handle, then
maybe it can be done. But if you have a lot of global class
variable etc that your cost function depends on, then it
will probably be too much work.

James Tursa

.



Relevant Pages

  • Re: Image processing prototype software
    ... two main complaints I have against MATLAB are no user interface ... Optimas (a now defunct package that had a lot of higher level ... ImageJ has a fairly user friendly user interface, ... time and cost as compared to getting a different package, ...
    (sci.image.processing)
  • Re: [SLE] Suse 9.3
    ... > cost will really damage the take-up. ... NO ONE who is a bigger supporter of SUSE than me. ... > compiling started to bore me. ... The only bug free software from MickySoft is still shrink-wrapped ...
    (SuSE)
  • Re: University License fees are short sighted of Wolfram Research
    ... number in science, engineering and maths courses, with lesser ... on the grounds of cost and the number of users. ... There must be 50+ staff using Matlab. ... The uni still has a site license - but since we don't contribute to that ...
    (sci.math.symbolic)
  • Re: OT: Smashed my laptop screen
    ... hehe, I did mine with a 386 25 SX, again a MFM HDD about 20mb I think, ... I was compiling C++ on it, ... I had to correct and wait another 10 mins... ... 1992, it was second hand, Cost me £100. ...
    (uk.games.video.xbox)
  • Re: Telecommuting
    ... The test equipment is downright cheap compared to the cost of the development software I use in my business. ... Even Matlab is comparatively cheap. ... Although he did say that he bought 3 or 4 toolboxes. ... plus the matching simulink tools. ...
    (comp.dsp)