coder.config

Package: coder

Create MATLAB Coder code generation configuration objects

Syntax

config_obj = coder.config
config_obj = coder.config('mex')
config_obj = coder.config('lib')
config_obj = coder.config('dll')
config_obj = coder.config('exe')
config_obj = coder.config(c_output_type,'ecoder',false)
config_obj = coder.config(c_output_type,'ecoder',true)
config_obj = coder.config('fixpt')
config_obj = coder.config('single')

Description

config_obj = coder.config creates a coder.MexCodeConfig code generation configuration object for use with codegen when generating a MEX function.

config_obj = coder.config('mex') creates a coder.MexCodeConfig code generation configuration object for use with codegen when generating a MEX function.

config_obj = coder.config('lib') creates a code generation configuration object for use with codegen when generating a C/C++ static library. If the Embedded Coder® product is installed, it creates a coder.EmbeddedCodeConfig object. Otherwise, it creates a coder.CodeConfig configuration object.

config_obj = coder.config('dll') creates a code generation configuration object for use with codegen when generating a C/C++ dynamic library. If the Embedded Coder product is installed, it creates a coder.EmbeddedCodeConfig object. Otherwise, it creates a coder.CodeConfig configuration object.

config_obj = coder.config('exe') creates a code generation configuration object for use with codegen when generating a C/C++ executable. If the Embedded Coder product is installed, it creates a coder.EmbeddedCodeConfig object. Otherwise, it creates a coder.CodeConfig configuration object.

config_obj = coder.config(c_output_type,'ecoder',false) creates a coder.CodeConfig configuration object to generate c_output_type even if the Embedded Coder product is installed. c_output_type is 'lib', 'dll', or 'exe'.

config_obj = coder.config(c_output_type,'ecoder',true) creates a coder.EmbeddedCodeConfig configuration object to generate c_output_type even if the Embedded Coder product is not installed. However, code generation using a coder.EmbeddedCodeConfig object requires an Embedded Coder license. c_output_type is 'lib', 'dll', or 'exe'.

config_obj = coder.config('fixpt') creates a coder.FixptConfig configuration object for use with codegen when generating fixed-point C/C++ code from floating-point MATLAB® code. Creation of a coder.FixptConfig code configuration object requires the Fixed-Point Designer™ product.

config_obj = coder.config('single') creates a coder.SingleConfig configuration object for use with codegen when generating single-precision MATLAB code from double-precision MATLAB code. Creation of a coder.SingleConfig code configuration object requires the Fixed-Point Designer product.

Examples

Generate a MEX function from a MATLAB function that is suitable for code generation and enable a code generation report.

  1. Write a MATLAB function, coderand, that generates a random scalar value from the standard uniform distribution on the open interval (0,1).

    function r = coderand() %#codegen
    % The directive %#codegen declares that the function
    % is intended for code generation
    r = rand();

  2. Create a code generation configuration object to generate a MEX function.

    cfg = coder.config % or cfg = coder.config('mex')

  3. Enable the code generation report.

    cfg.GenerateReport = true;
  4. Generate a MEX function in the current folder specifying the configuration object using the -config option.

    % Generate a MEX function and code generation report
    codegen -config cfg coderand

Create a code generation configuration object to generate a standalone C static library.

cfg = coder.config('lib')
% Returns a coder.EmbeddedCodeConfig object if the Embedded 
% Coder product is installed. 
% Otherwise, returns a coder.CodeConfig object.

Create a code generation configuration object to generate a standalone C dynamic library.

cfg = coder.config('dll')
% Returns a coder.EmbeddedCodeConfig object if the Embedded 
% Coder product is installed. 
% Otherwise, returns a coder.CodeConfig object.

Create a code generation configuration object to generate a standalone C executable.

cfg = coder.config('exe')
% Returns a coder.EmbeddedCodeConfig object if the Embedded 
% Coder product is installed. 
% Otherwise, returns a coder.CodeConfig object.

Create a coder.CodeConfig object even if the Embedded Coder product is installed .

cfg = coder.config('lib','ecoder',false)
% Returns a coder.CodeConfig object even if the Embedded 
% Coder product is installed.

Create a floating-point to fixed-point conversion configuration object.

fixptcfg = coder.config('fixpt');
% Returns a coder.FixptConfig object

Create a double-precision to single-precision conversion configuration object.

scfg = coder.config('single');
% Returns a coder.SingleConfig object

Alternatives

Use the coder function to open the MATLAB Coder™ app and create a MATLAB Coder project. The app provides a user interface that facilitates adding MATLAB files, defining input parameters, and specifying build parameters.

Introduced in R2011a

Was this topic helpful?