Using the C Math Library |
 |
Extending the mlfFeval() Table
To extend the built-in mlfFeval()
table, you must:
- Write the function that you want a function-function to execute.
- Write a thunk function that knows how to call your function.
- 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.
- 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:
- 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.
- Extract the input arguments from the input argument array.
- Call the function that was passed to it.
- Place the results from the function call into the output array.
Note
You don't need to write a thunk function if you want a function-function to execute a MATLAB C Math Library function. A thunk function and an entry in the built-in table already exist.
|
| How mlfFeval() Works | | Example - Passing Functions As Arguments (ex4.c) |  |