Code Generation for Nested Functions - MATLAB & Simulink (original) (raw)

Main Content

You can generate code for MATLABĀ® functions that contain nested functions. For example, you can generate code for the function parent_fun, which contains the nested function child_fun.

function parent_fun x = 5; child_fun

function child_fun
    x = x + 1;
end

end

Nested Function Limitations for Code Generation

When you generate code for nested functions, you must adhere to the code generation restrictions for value classes, cell arrays, and handle classes. You must also adhere to these restrictions: