Main Content

Exception by function


Specify how input array data is handled by each external C function.

Category: Simulation Target


Specify how input array data is handled by each external C function in your custom code. The array layout specified for an individual function takes precedence over the option specified in Default function array layout. Use these options to add or remove the array layout setting for an individual C function:

green plus sign Add

Add custom C function and specify its array layout setting.

red letter x Remove

Remove custom C function from the exception list and apply default array layout to the function.


If you do not see a list of your custom code functions in the Exception by function dialog, close the dialog, click Validate, and click Exception by function again.

Command-Line Information

Parameter: CustomCodeFunctionArrayLayout
Type: structure array
Value: structure with 'FunctionName' and 'ArrayLayout' fields. 'ArrayLayout' can be 'Column-major', 'Row-major' or 'Any'.
Default: ' '


Consider the model foo_model. If you have external C functions that you interface with the model, execute these MATLAB® commands to specify array layouts for the functions.

arrayLayout(1).FunctionName = 'MyCFunction1';
arrayLayout(1).ArrayLayout = 'Column-major';
arrayLayout(2).FunctionName = 'MyCFunction2';
arrayLayout(2).ArrayLayout = 'Row-major';
set_param('foo_model', 'CustomCodeFunctionArrayLayout', arrayLayout)

Recommended Settings

DebuggingNo impact
TraceabilityNo impact
EfficiencyNo recommendation
Safety precautionNo recommendation

Related Topics