Configuring Your Environment for Code Generation

Types of Configuration Objects

Embedded MATLAB Coder provides configuration objects for customizing your environment for code generation. You can create the following configuration objects:

Configuration ObjectDescriptionDefault TargetParameter 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.

Working with Configuration Objects

To use configuration objects to customize your environment for code generation, follow these steps:

  1. 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
  2. Modify the parameters of the configuration object as necessary, using one of these methods:

  3. 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.

Creating Configuration Objects

You can define a configuration object in the MATLAB workspace, as follows:

To Create:Use a Constructor Command Like This
C MEX configuration objectmexcfg = emlcoder.MEXConfig
Real-Time Workshop configuration object for generating embeddable C codertwcfg = emlcoder.RTWConfig
Hardware implementation configuration objecthwcfg = emlcoder.HardwareImplementation
Compiler options configuration objectcocfg = 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.

Modifying Configuration Objects

There are two ways to modify the values of configuration objects for Embedded MATLAB Coder.

Modifying Configuration Objects at the Command Line Using Dot Notation

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:

Modifying Configuration Objects Using Dialog Boxes

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.

Saving Configuration Objects

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.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS