How to pass arguments when calling lsqnonlin from C++ with mexCallMATLAB?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to run lsqnonlin which is a matlab optimization function from C++. From matlab it is called as follows:
lsqnonlin(@(x)funcHandle(x,var1,var2,..),x_initial,[],[],options);
From metlab c++ API I understood that mexCallMATLAB is the function I should use to call matlab and get the output
int mexCallMATLAB(int nlhs, mxArray *plhs[], int nrhs,mxArray *prhs[],
const char *functionName);
how do I pass all the arguments to mexCallMATLAB - {funcHandle,var1,var2,..,x_initial,[],[],options}, especially the function handle? I found this "mclCreateSimpleFunctionHandle" function, but I'm not sure how to use it? I have a mexFunction implementation of the funcHandle, and created a mexw64 version of it, I think I should use that somehow..
Thanks
1 Kommentar
James Tursa
am 13 Jan. 2016
Are you passing the result of @(x)funcHandle(x,var1,var2,...) into the mex function? I.e., are you creating the anonymous function handle at the m-file level and then passing that into the mex routine and wondering how to call mexCallMATLAB with this?
Or are you creating var1, var2, etc inside the mex function, and then wondering how to create the function handle inside the mex routine to use to pass to lsqnonlin via mexCallMATLAB?
Antworten (0)
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!