About Embedded MATLAB MEX

Optimizes M-Code for Run-Time Efficiency

Embedded MATLAB MEX is a function that optimizes M-code for run-time efficiency in the following applications:

ApplicationWhat Embedded MATLAB MEX Does
Accelerate fixed-point calculationsConverts M-code to C-MEX functions that contain Embedded MATLAB optimizations for automatically accelerating fixed-point algorithms to compiled C code speed.

    Note   You can also generate optimized C-MEX functions from source-protected P-code. See eml.allowpcode.

Run M-code in SimulinkChecks M-code for compliance with Embedded MATLAB syntax and semantics, as described in Working with the Embedded MATLAB Subset. You can add compliant code to:
  • Embedded MATLAB Function blocks and Truth Table blocks in Simulink models

  • Embedded MATLAB functions and Truth Table functions in Stateflow charts

MEX-files are dynamically linked subroutines that the MATLAB interpreter can automatically load and execute. C-MEX files are MEX-files that are written in the C programming language, but can run directly in MATLAB. For more information, see Using MEX-Files to Call C and Fortran Programs in the MATLAB External Interfaces documentation.

Running a Demo for Embedded MATLAB MEX

Fixed-Point Toolbox software ships with a demonstration of how to generate a C-MEX function from M-code. The M-code takes the weighted average of a signal to create a lowpass filter. If you have a Fixed-Point Toolbox license, you can run the demo by following these steps:

  1. Install Fixed-Point Toolbox.

  2. At the MATLAB prompt, type this command:

    demos

    The Help browser appears, listing categories of demos in the left pane.

  3. In the left pane, navigate to Toolboxes > Fixed-Point > Fixed-Point Lowpass Filtering Using Embedded MATLAB MEX.

  4. Follow the instructions in the right pane of the Help browser.

How Embedded MATLAB MEX Resolves Function Calls

Embedded MATLAB MEX resolves function calls by first searching the Embedded MATLAB path and then the MATLAB path. By default, Embedded MATLAB MEX tries to compile and generate code for functions it finds on the path unless you explicitly declare the function to be extrinsic. Embedded MATLAB does not compile extrinsic functions, but rather dispatches them to MATLAB for execution. For more information, see How the Embedded MATLAB Subset Resolves Function Calls in the Embedded MATLAB documentation.

  


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