How to pass arguments when calling lsqnonlin from C++ with mexCallMATLAB?
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
James Tursa
2016-1-13
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?
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!