Main Content

Compilation Directive %#codegen

Add the %#codegen directive (or pragma) to your function after the function signature to indicate that you intend to generate code for the MATLAB® algorithm. Adding this directive instructs the MATLAB Code Analyzer to help you diagnose and fix violations that would result in errors during code generation.

function y = my_fcn(x) %#codegen



The %#codegen directive is not necessary for MATLAB Function blocks. Code inside a MATLAB Function block is always intended for code generation. The %#codegen directive, or the absence of it, does not change the error checking behavior.