How to pass arguments when calling lsqnonlin from C++ with mexCallMATLAB?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
James Tursa
el 13 de En. de 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?
Respuestas (0)
Ver también
Categorías
Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!