Can I pass a C or shared library function to FMINSEARCH, FZERO or other function with takes an MATLAB function handle as input?
1 回表示 (過去 30 日間)
古いコメントを表示
I would like to pass a C or shared library function to a function such as FMINSEARCH, which expects an MATLAB function handle as input and iteratively finds a minimum of the function.
採用された回答
MathWorks Support Team
2010 年 1 月 22 日
You can use your C or shared library function in the folowing manner:
If you are using a C function, first call this function from a MEX-file, and then call the MEX-file from an MATLAB function. Pass the handle to the wrapper MATLAB function to FMINSEARCH.
For more information about the process of compiling and calling a simple MEX file from MATLAB, see the documentation chapter on "Creating C Language MEX-Files".
If you are using a shared library (DLL) function, write an MATLAB function which uses the LOADLIBRARY and CALLLIB commands to call your shared library function. You can then pass a handle to this wrapper MATLAB function to FMINSEARCH.
For more information, see the documentation chapter on "MATLAB Interface to Generic DLLs".
For information about using C or shared library functions with FMINSEARCH or other MATLAB function which takes an MATLAB function handle as input, please see the Related Solution below.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で File Operations についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!