| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |

| On this page… |
|---|
Simulation Target: Custom Code Tab Overview Use local custom code settings (do not inherit from main model) |
Include custom code settings for a model that contains Embedded MATLAB Function blocks, Stateflow charts, or Truth Table blocks.
Select the type of information to include from the list on the left side of the pane.
Enter a string to identify the specific code, directory, source file, or library.
Click Apply.
Enter code lines to appear near the top of a generated source code file.
Default: ' '
Code lines appear near the top of the generated model.c source file, outside of any function.
| Parameter: SimCustomSourceCode |
| Type: string |
| Value: any source file name |
| Default: '' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact |
Enter code lines to appear near the top of a generated header file.
Default: ' '
Code lines appear near the top of the generated model.h header file.
When you include a custom header file, enclose the file name in double quotes. For example, #include "sample_header.h" is a valid declaration for a custom header file.
You can include extern declarations of variables or functions.
| Parameter: SimCustomHeaderCode |
| Type: string |
| Value: any header file name |
| Default: '' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact |
Enter code statements that execute once at the start of simulation.
Default: ' '
Code appears inside the model's initialize function in the model.c file.
Use this code to invoke functions that allocate memory or to perform other initializations of your custom code.
| Parameter: SimCustomInitializer |
| Type: string |
| Value: any code |
| Default: '' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact |
Enter code statements that execute at the end of simulation.
Default: ' '
Code appears inside the model's terminate function in the model.c file.
Use this code to invoke functions that free memory allocated by the custom code or to perform other cleanup tasks.
| Parameter: SimCustomTerminator |
| Type: string |
| Value: any code |
| Default: '' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact |
Specify a list of directory paths that contain files you include in the compiled target.
Default:''
Enter a space-separated list of directory paths.
Specify absolute or relative paths to the directories.
Relative paths must be relative to the directory containing your model files, not relative to the build directory.
The order in which you specify the directories is the order in which they are searched for header, source, and library files.
Note If you specify a Windows® path string containing one or more spaces, you must enclose the string in double quotes. For example, the second and third path strings in the Include directories entry below must be double-quoted: C:\Project "C:\Custom Files" "C:\Library Files" If you set the equivalent command-line parameter SimUserIncludeDirs, each path string containing spaces must be separately double-quoted within the single-quoted third argument string, for example, >> set_param('mymodel', 'SimUserIncludeDirs', ...
'C:\Project "C:\Custom Files" "C:\Library Files"') |
| Parameter: SimUserIncludeDirs |
| Type: string |
| Value: any directory file name |
| Default: '' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact |
Specify a list of source files to compile and link into the target.
Default:''
You can separate source files with a comma, a space, or a new line.
Note If you specify a Windows file name string containing one or more spaces, you must enclose the string in double quotes. For example, the second and third name strings in the Source files entry below must be double-quoted: algs.c "div alg.c" "sin alg.c" If you set the equivalent command-line parameter SimUserSources, each file name string containing spaces must be separately double-quoted within the single-quoted third argument string, for example, >> set_param('mymodel', 'SimUserSources', ...
'algs.c "div alg.c" "sin alg.c"') |
The file name is sufficient if the file is in the current MATLAB directory or in one of the include directories.
| Parameter: SimUserSources |
| Type: string |
| Value: any source file name |
| Default: '' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact |
Specify a list of static libraries that contain custom object code to link into the target.
Default:''
Enter a space-separated list of library files.
Note If you specify a Windows file name string containing one or more spaces, you must enclose the string in double quotes. For example, the second and third name strings in the Libraries entry below must be double-quoted: mathutil.lib "op utils.lib" "fx utils.lib" If you set the equivalent command-line parameter SimUserLibraries, each file name string containing spaces must be separately double-quoted within the single-quoted third argument string, for example, >> set_param('mymodel', 'SimUserLibraries', ...
'mathutil.lib "op utils.lib" "fx utils.lib"') |
The file name is sufficient if the file is in the current MATLAB directory or in one of the include directories.
| Parameter: SimUserLibraries |
| Type: string |
| Value: any library file name |
| Default: '' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact |
Specify if a library model can use custom code settings that are unique from the main model.
Default: Off
Enables a library model to use custom code settings that are unique from the main model.
Disables a library model from using custom code settings that are unique from the main model.
This parameter is available only for library models that contain Embedded MATLAB Function blocks, Stateflow charts, or Truth Table blocks. To access this parameter, select Tools > Open Simulation Target in the Embedded MATLAB Editor or Stateflow Editor for your library model.
| Parameter: SimUseLocalCustomCode |
| Type: string |
| Value: 'on' | 'off' |
| Default: 'off' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact |
![]() | Simulation Target Pane: Symbols | Library Browser | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |