Can I pass a C or shared library function to FMINSEARCH, FZERO or other function with takes an MATLAB function handle as input?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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.
Respuesta aceptada
MathWorks Support Team
el 22 de En. de 2010
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre File Operations en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!