Can I pass a C or shared library function to FMINSEARCH, FZERO or other function with takes an MATLAB function handle as input?

조회 수: 2 (최근 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
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개)

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by