Products & Services Solutions Academia Support User Community Company

eml.allowpcode - Package: eml

Allow compilation of protected Embedded MATLAB compliant M-code

Syntax

eml.allowpcode('plain')

Description

eml.allowpcode('plain') allows you to generate protected M-code (P-code) that you can then compile into optimized C-MEX functions or embeddable C code. This function does not obfuscate the generated C-MEX functions or embeddable C code.

With this capability, you can distribute algorithms as protected P-files that provide Embedded MATLAB optimizations, providing intellectual property protection for your source M-code.

Call this function in the top-level function before any control-flow statements, such as if, while, switch, and function calls.

Embedded MATLAB functions can call P-code. When the .m and .p versions of a file exist in the same directory, the P-file always takes precedence.

eml.allowpcode has no effect in MATLAB code; it applies to the Embedded MATLAB subset only.

Examples

Generate optimized embeddable code from protected M-code:

  1. Write an M-function p_abs that returns the absolute value of its input:

    function out = p_abs(in)   %#eml
    % The directive %#eml declares the function
    % to be Embedded MATLAB compliant
    eml.allowpcode('plain');
    out = abs(in);
  2. Generate protected P-code. At the MATLAB prompt, enter:

    pcode p_abs

    The P-file, p_abs.p, appears in the current folder.

  3. Generate a C-MEX function for p_abs.p, using the -eg option to specify the size, class, and complexity of the input parameter. At the MATLAB prompt, enter:

    emlmex p_abs -eg { int32(0) }

    emlmex generates a C-MEX function in the current folder.

  4. Generate embeddable C code for p_abs.p (requires a Real-Time Workshop® license). At the MATLAB prompt, enter:

    emlc p_abs -T rtw:lib -eg { int32(0) };

    emlc generates C library code in the emcprj\rtwlib\p_abs folder.

See Also

emlc | emlmex | pcode

How To

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

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