| Contents | Index |
| On this page… |
|---|
Working with the MEX Compiler Configuration Object Modifying Compilation Options at the Command Line Using Dot Notation |
For MEX code generation, MATLAB provides a configuration object coder.MEXConfig for fine-tuning the compilation. To set MEX compilation options:
Define the compiler configuration object in the MATLAB workspace by issuing a constructor command:
comp_cfg = coder.mexconfig
MATLAB displays the list of compiler options and their current values in the command window.
Modify the compilation options as necessary. See Modifying Compilation Options at the Command Line Using Dot Notation
Invoke fiaccel with the -config option and specify the configuration object as its argument:
fiaccel -config comp_cfg myMfile
The -config option instructs fiaccel to convert myFile.m to a MEX function, based on the compilation settings in comp_cfg.
Use dot notation to modify the value of compilation options, using this syntax:
configuration_object.property = value
Dot notation uses assignment statements to modify configuration object properties. For example, to change the maximum size function to inline and the stack size limit for inlined functions during MEX generation, enter this code at the command line:
co_cfg = coder.MEXConfig co_cfg.InlineThreshold = 25; co_cfg.InlineStackLimit = 4096; fiaccel -config co_cfg myFun
The following table describes parameters for fine-tuning the behavior of fiaccel for converting MATLAB files to MEX:
| Parameter | Equivalent
Command-Line Property and Values (default in bold) | Description |
|---|---|---|
| Report | ||
| Create code generation report | GenerateReport true, false | Document generated code in an HTML report. |
| Launch report automatically | LaunchReport true, false | Specify whether to automatically display HTML reports after code generation completes. |
| Debugging | ||
| Echo expressions without semicolons | EchoExpressions true, false | Specify whether or not actions that do not terminate with a semicolon appear in the MATLAB Command Window. |
| Enable debug build | EnableDebugging true, false | Compile the generated code in debug mode. |
| Language and Semantics | ||
| Constant Folding Timeout | ConstantFoldingTimeout integer, 10000 | Specify the maximum number of instructions to be executed by the constant folder. |
| Dynamic memory allocation | DynamicMemoryAllocation 'off', 'AllVariableSizeArrays' | Enable dynamic memory allocation for variable-size data. By default, dynamic memory allocation is disabled and fiaccel allocates memory statically on the stack. When you select dynamic memory allocation, fiaccel allocates memory for all variable-size data dynamically on the heap. You must use dynamic memory allocation for all unbounded variable-size data. |
| Enable variable sizing | EnableVariableSizing true, false | Enable support for variable-size arrays. |
| Extrinsic calls | ExtrinsicCalls true, false | Allow calls to extrinsic functions. When enabled (true), the compiler generates code for the call to a MATLAB function, but does not generate the function's internal code. When disabled (false), the compiler ignores the extrinsic function. Does not generate code for the call to the MATLAB function—as long as the extrinsic function does not affect the output of the caller function. Otherwise, the compiler issues a compiler error. |
| Global Data Synchronization Mode | GlobalDataSyncMethod string,SyncAlways, SyncAtEntryAndExits, NoSync | Controls when global data is synchronized with the MATLAB global workspace. By default, (SyncAlways), synchronizes global data at MEX function entry and exit and for all extrinsic calls. This synchronization ensures maximum consistency between MATLAB and generated code. If the extrinsic calls do not affect global data, use this option with the coder.extrinsic -sync:off option to turn off synchronization for these calls. SyncAtEntryAndExits synchronizes global data at MEX function entry and exit only. If only a few extrinsic calls affect global data, use this option with the coder.extrinsic -sync:on option to turn on synchronization for these calls. NoSync disables synchronization. Ensure that your generated code does not interact with MATLAB before disabling synchronization. Otherwise, inconsistencies might occur. |
| Saturate on integer overflow | SaturateOnIntegerOverflow true, false | Add checks in the generated code to detect integer overflow or underflow. |
| Safety (disable for faster MEX) | ||
| Ensure memory integrity | IntegrityChecks true, false | Detects violations of memory integrity in code generated from MATLAB algorithms and stops execution with a diagnostic message. Setting IntegrityChecks to false also disables the run-time stack. |
| Ensure responsiveness | ResponsivenessChecks true, false | Enables responsiveness checks in code generated from MATLAB algorithms. |
| Function Inlining and Stack Allocation | ||
| Inline Stack Limit | InlineStackLimit integer, 4000 | Specify the stack size limit on inlined functions. |
| Inline Threshold | InlineThreshold integer, 10 | Specify the maximum size of functions to be inlined. |
| Inline Threshold Max | InlineThresholdMax integer, 200 | Specify the maximum size of functions after inlining. |
| Stack Usage Max | StackUsageMax integer, 200000 | Specify the maximum stack usage per application in bytes. Set a limit that is lower than the available stack size. Otherwise, a runtime stack overflow might occur. Overflows are detected and reported by the C compiler, not by fiaccel. |
| Optimizations | ||
| Use BLAS library if possible | EnableBLAS true, false | Speed up low-level matrix operations during simulation by calling the Basic Linear Algebra Subprograms (BLAS) library. |
How Working with Variable-Size Data Is Different for Code Generation
Generating MEX Functions from MATLAB Code That Uses Global Data
fiaccel takes the union of all options, including those specified using configuration objects, so that you can specify options in any order.
![]() | Preparing MATLAB Algorithms for Code Generation | Specifying Properties of Primary Function Inputs | ![]() |

Learn how to apply early verification to your development process through these technical resources.
How much time do you spend on testing to ensure implementation meets system-level requirements?
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |