Re: Call a MEX function from Matlab Engine?
- From: "James Tursa" <aclassyguywithaknotac@xxxxxxxxxxx>
- Date: Sat, 15 Mar 2008 22:15:07 +0000 (UTC)
"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
.
- References:
- Call a MEX function from Matlab Engine?
- From: David Doria
- Re: Call a MEX function from Matlab Engine?
- From: James Tursa
- Re: Call a MEX function from Matlab Engine?
- From: David Doria
- Re: Call a MEX function from Matlab Engine?
- From: James Tursa
- Re: Call a MEX function from Matlab Engine?
- From: David Doria
- Re: Call a MEX function from Matlab Engine?
- From: James Tursa
- Re: Call a MEX function from Matlab Engine?
- From: David Doria
- Re: Call a MEX function from Matlab Engine?
- From: James Tursa
- Re: Call a MEX function from Matlab Engine?
- From: David Doria
- Re: Call a MEX function from Matlab Engine?
- From: James Tursa
- Re: Call a MEX function from Matlab Engine?
- From: David Doria
- Call a MEX function from Matlab Engine?
- Prev by Date: Cursor FFT and selected region
- Next by Date: Re: Statistics toolbox with Matlab R2007b
- Previous by thread: Re: Call a MEX function from Matlab Engine?
- Next by thread: newnarx in 2007b Error
- Index(es):
Relevant Pages
|