Function Handle Limitations for Code Generation
When you use function handles in MATLAB® code intended for code generation, adhere to the following restrictions:
Do not use the same variable to reference different function handles
Do not pass function handles to or from coder.ceval
Do not associate a function handle with an extrinsic function
Do not pass function handles to or from extrinsic functions
Do not pass function handles to or from entry-point functions