Using the C Math Library    

Extending the mlfFeval() Table

To extend the built-in mlfFeval() table, you must:

  1. Write the function that you want a function-function to execute.
  2. Write a thunk function that knows how to call your function.
  3. Declare a local function table and add the name of your function, a pointer to your function, and a pointer to your thunk function to that table.
  4. Register the local table with mlfFeval().

Note that your program can't contain more than 64 local function tables, but each table can contain an unlimited number of functions.

Writing a Thunk Function

A thunk function must:

  1. Ensure that the number of arguments in the input and output arrays matches the number of arguments required by the function to be executed. Remember that functions in the MATLAB C Math Library can have optional arguments.
  2. Extract the input arguments from the input argument array.
  3. Call the function that was passed to it.
  4. Place the results from the function call into the output array.


 How mlfFeval() Works Example - Passing Functions As Arguments (ex4.c)