MATLAB: How to remove the “eml_” prefix on the variables in the C code produced by EMLC

controleml_emlcprefixremovesimulink coder

I want to control the format of the variables in the code produced by EMLC.

Best Answer

It is sometimes desirable to remove the "eml_" prefix that Embedded MATLAB prepends to variable names in the generated C-Code. This is supported in Real-Time Workshop (RTW) 7.3 (R2009a), but this also requires that you have a license for Real-Time Workshop Embedded Coder (RTW-EC).
Note that this feature is not available in versions previous to R2009a.
The following are the steps for removing the “eml_” prefix:
1. At the command line (or in a build script), type:
cfg = emlcoder.RTWConfig('ert');
cfg.CustomSymbolStrTmpVar = '$M$N';
These commands create a configuration object, called 'cfg', that provides many properties that you can use to control the generated code. If you want to see what properties are available, type:
open cfg
at the command line to open a GUI that allows you to inspect and modify the properties. Alternatively, you can type 'cfg' at the command line to see the properties as a list in the Command Window.
2. Then, when you invoke the 'emlc' command, use the '-s' option to pass the 'cfg' object to the Embedded MATLAB Coder. So, for example:
emlc myfunc -eg { ... } -s cfg
where 'myfunc' is the name of the MATLAB file containing the MATLAB source code for your function.