How to pass arguments when calling lsqnonlin from C++ with mexCallMATLAB?

4 ビュー (過去 30 日間)
Anna Shtengel
Anna Shtengel 2016 年 1 月 7 日
コメント済み: James Tursa 2016 年 1 月 13 日
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
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 件)

カテゴリ

Help Center および File ExchangeWrite C Functions Callable from MATLAB (MEX Files) についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by