call fmincon from vc6.0 where the objf and constraints vary from arguments

I use mcc to compiler fmincon to
myfmincon(int nargout, mwArray& x, mwArray& fval, mwArray& exitflag, const mwArray& myfun, const mwArray& xx0, const mwArray& A, const mwArray& B, const mwArray& Aeq, const mwArray& Beq, const mwArray& LB, const mwArray& UB, const mwArray& mycon);
Now i have myfun and mycon defined in vc6.0 and they have different expressions varying from the input,someone like following:
double myfun(double x[])
{
double f = 0;
int N = 100;
for(int i=0; i < N; i++)
f = f+x[i]*x[N-i];
return f;
}
double mycon(double x[], double y[])
{
...
return...
}
So, how i can use fmincon in this situation, someone have any ideas? Thanks very much!
Edit [30 Jul 2012, 14:24 BST - OK] Embedded info from answer
in the function fmincon, myfun and mycon are function handles, so how can i define variables in c++ to pass to fmincon(dll)?

2 Comments

Thanks very much, i will read it carefully and format my questions later

Answers (0)

This question is closed.

Asked:

on 26 Jul 2012

Closed:

on 20 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!