Skip to Main Content Skip to Search
Home |   Australia  Choose Country  |  Contact Us  |  Cart Store 
Create Account | Log In
Products & Services Industries Academia Support User Community Company

Using Embedded MATLAB Code for Simulation and Code Generation

Explore Embedded MATLAB

Working with the Embedded MATLAB Subset

An inference engine enforces Embedded MATLAB language subset constraints for simulation and code generation. Real-Time Workshop employs this engine to convert code written in MATLAB (a dynamically typed language) to C (a statically typed language), without using dynamic memory allocation.

To convert data types accurately, the inference engine requires that you define the class, size, and complexity of data in the source Embedded MATLAB code so the engine can assign data types correctly at compile time.

See the Working with Embedded MATLAB documentation for details on these constraints and coding practices.

Capabilities for MATLAB Users

With MATLAB code written using the Embedded MATLAB subset, you can:

Develop and Execute Embeddable Algorithms

You can use MATLAB and Fixed-Point Toolbox to write and simulate embeddable floating-point and fixed-point algorithms contained in one or more M-files. The emlmex command automatically converts the Embedded MATLAB code into a MEX-file, which executes at compiled C speed.

The emlmex command also helps you verify compliance of your algorithm with the Embedded MATLAB subset. It checks for potential syntax violations and automatically generates a compilation report detailing compliance issues. (Requires Fixed-Point Toolbox or Simulink) In addition, you can check for compliance of your M-file with the Embedded MATLAB syntax by using the M-Lint code analyzer in MATLAB.

Generate Embedded C Code Directly from MATLAB M-files

Using Real-Time Workshop, you can generate efficient, embeddable C code from MATLAB code in M-files using the emlc command, directly from the MATLAB desktop.

Related products: MATLAB, Fixed-Point Toolbox, Real-Time Workshop

Capabilities for Simulink Users

You can use Embedded MATLAB code within the Simulink product family to:

Include Embedded-Ready MATLAB Code in Simulink Models

You can call Embedded MATLAB functions contained in one or more M-files on the MATLAB path from Embedded MATLAB Function blocks in Simulink block diagram models, Embedded MATLAB functions in Stateflow® charts, and Attribute blocks in SimEvents® discrete-event models. This allows you to create libraries of Embedded MATLAB code that can be reused in multiple Simulink models. As a result, you can combine graphical models and MATLAB code in Simulink to develop, simulate, and verify algorithms in a complete system-level context.

You can also perform code checking of Embedded MATLAB language subset functions with Simulink Design Verifier™.

Generate Embeddable C Code

You can use Real-Time Workshop to generate efficient embedded C code from Simulink and Stateflow models containing Embedded MATLAB code. The code can be deployed and verified on target hardware using links to embedded IDEs and target support packages for a variety of processors.

Generate VHDL and Verilog

Using Simulink HDL Coder, you can generate synthesizable VHDL and Verilog from Embedded MATLAB Function blocks in Simulink and Embedded MATLAB functions in Stateflow.

Related products: Simulink, Stateflow, SimEvents, Simulink Design Verifier, Simulink HDL Coder

Working with the Embedded MATLAB subset, you can you can generate C code automatically from MATLAB, and include MATLAB algorithms in Simulink models for efficient system simulation and code generation.

Working with products that support the Embedded MATLAB subset, you can generate C and HDL automatically from MATLAB, and include MATLAB algorithms in Simulink models for efficient system simulation and code generation.

Click on image to see enlarged view.

Contact sales
E-mail this page