Code Generation by Using Embedded Coder - MATLAB & Simulink (original) (raw)

Main Content

Code Generation Technology

MathWorks® code generation technology produces C or C++ code and executable programs for algorithms. You can write algorithms programmatically by using MATLAB® or graphically in the Simulink® environment. You can generate code for MATLAB functions and Simulink blocks that are useful for real-time and embedded applications. Generated source code and executable programs for floating-point algorithms match the functional behavior of MATLAB code execution and Simulink simulations to a high degree of fidelity. Using the Fixed-Point Designer product, you can generate fixed-point code that provides a bitwise match to model simulation results. Such broad support and high degree of accuracy are possible because code generation is tightly integrated with the MATLAB and Simulink execution and simulation engines. The built-in accelerated simulation modes in Simulink use code generation technology.

When designing components or a complete application in the Simulink environment, you can generate code from your models by using Simulink Coder™ or Embedded Coder®.

Code generation technology and related products provide tooling that you can apply to the V-model for system development. The V-model is a representation of system development that highlights verification and validation steps in the development process. For more information, see Validation and Verification for System Development.

Code Generation Workflows with Embedded Coder

The Embedded Coder product extends the MATLAB Coder and Simulink Coder products with features that you can use for embedded software development. Using the Embedded Coder product, you can generate code that has the clarity and efficiency of user-written code. For example, you can:

You can design, implement, and verify generated C or C++ code from Simulink models or MATLAB code.

Other products that support code generation, such as Stateflow® software, are available.

To generate C or C++ code from Simulink models by using Embedded Coder, you need these products:

You can implement algorithms as Simulink blocks and Stateflow charts in a Simulink model. Embedded Coder provides features for designing, configuring, and verifying a model for C or C++ code generation.

If you have algorithms written in MATLAB code, you can include the MATLAB code in a Simulink model or subsystem by using the MATLAB Function block. When you generate C or C++ code for the model, the MATLAB code in the MATLAB Function block is included in the generated code as C or C++ source code.

To get started generating code from Simulink models by using Embedded Coder, see Generate C Code from Simulink Models.

Code Generation from MATLAB Code

To generate code C or C++ code from MATLAB code by using Embedded Coder, you need these products:

MATLAB Coder supports a subset of core MATLAB language features, including program control constructs, functions, and matrix operations. To generate C or C++ code, you can use MATLAB Coder projects or enter the function codegen in the MATLAB Command Window. Embedded Coder provides additional options and advanced optimizations for fine-grain control of generated code functions, files, and data. For more information about these options and optimizations , see Embedded Coder Capabilities for Code Generation from MATLAB Code.

For more information about generating code from MATLAB code, see Overview of Code Generation Using MATLAB Coder.

To get started generating code from MATLAB code by using Embedded Coder, see Embedded Coder Capabilities for Code Generation from MATLAB Code.