| Real-Time Workshop® | ![]() |
| On this page… |
|---|
Types of Configuration Objects Working with Configuration Objects Creating Configuration Objects |
Embedded MATLAB Coder provides configuration objects for customizing your environment for code generation. You can create the following configuration objects:
| Configuration Object | Description | Default Target | Parameter Reference |
|---|---|---|---|
emlcoder.MEXConfig | Specifies parameters for C MEX code generation (for C MEX builds only) | mex (generates C MEX code unless you specify a different target) | See Automatic C MEX Generation Dialog Box for Embedded MATLAB Coder in the Real-Time Workshop Reference documentation. |
emlcoder.CompilerOptions | Specifies parameters for fine-tuning compilation. | See Compiler Options Dialog Box in the Embedded MATLAB documentation. | |
emlcoder.RTWConfig | Specifies parameters for embeddable C code generation (for Real-Time Workshop builds only). | rtw:lib (generates an embeddable C library unless you specify a different target) | See Real-Time Workshop Dialog Box for Embedded MATLAB Coder in the Real-Time Workshop Reference documentation. |
emlcoder.HardwareImplementation | Specifies parameters of the target hardware implementation (for Real-Time Workshop builds only). If not specified, Embedded MATLAB Coder generates code that is compatible with the MATLAB host computer. | See Hardware Implementation Dialog Box for Embedded MATLAB Coder in the Real-Time Workshop Reference documentation. |
For more information about the association between configuration objects and targets, see Choosing Your Target.
To use configuration objects to customize your environment for code generation, follow these steps:
Define configuration object variables in the MATLAB workspace, as described in Creating Configuration Objects.
For example, the following command defines a Real-Time Workshop configuration object variable called rtwcfg:
rtwcfg = emlcoder.RTWConfig
Modify the parameters of the configuration object as necessary, using one of these methods:
Interactive commands, as described in Modifying Configuration Objects at the Command Line Using Dot Notation
Graphical user interface, as described in Modifying Configuration Objects Using Dialog Boxes
Invoke Embedded MATLAB Coder with the -s option and specify the configuration object as its argument.
The -s option instructs Embedded MATLAB Coder to generate code for the target, based on the configuration property values. In the following example, Embedded MATLAB Coder generates a C code library from an M-file myMfile.m, based on the parameters of a Real-Time Workshop configuration object rtwcfg defined in the first step:
emlc -T rtw:lib -s rtwcfg myMfile
Note that the -T option specifies the type of target you want to build — in this case, a library of embeddable C code. For more information about invoking Embedded MATLAB Coder, see emlc in the Real-Time Workshop Function Reference.
You can define a configuration object in the MATLAB workspace, as follows:
| To Create: | Use a Constructor Command Like This |
|---|---|
| C MEX configuration object | mexcfg = emlcoder.MEXConfig |
| Real-Time Workshop configuration object for generating embeddable C code | rtwcfg = emlcoder.RTWConfig |
| Hardware implementation configuration object | hwcfg = emlcoder.HardwareImplementation |
| Compiler options configuration object | cocfg = emlcoder.CompilerOptions |
Each configuration object comes with a set of parameters, initialized to default values (see Embedded MATLAB Coder Configuration Parameters in the Real-Time Workshop Reference documentation). You can change these settings as described in Modifying Configuration Objects.
There are two ways to modify the values of configuration objects for Embedded MATLAB Coder.
You can use dot notation to modify the value of one configuration object parameter at a time, using this syntax:
configuration_object.property = value
Dot notation uses assignment statements to modify configuration object properties:
To specify a main function during C code generation, enter this code at the command line:
rtwcfg = emlcoder.RTWConfig rtwcfg.CustomInclude = 'c:\myfiles'; rtwcfg.CustomSource = 'main.c'; emlc -T rtw:exe -s rtwcfg myFun
To automatically generate and launch HTML reports after generating a C library, enter this code:
rtwcfg = emlcoder.RTWConfig rtwcfg.GenerateReport= true rtwcfg.LaunchReport = true emlc -T rtw:lib -s rtwcfg myFun
Besides using commands, you can modify code generation parameters using dialog boxes. To learn how to work with these dialog boxes, see Embedded MATLAB Coder Configuration Parameters in the Real-Time Workshop Reference documentation.
Configuration objects do not automatically persist between MATLAB sessions, but there are two ways to preserve your settings:
Save a configuration object to a MAT-file and then load the
MAT-file at your next session
Write a script that creates the configuration object and sets
its properties.
![]() | Making M-Code Compliant with the Embedded MATLAB Subset | Specifying Properties of Primary Function Inputs | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |