Generate Fixed-Point MATLAB Code for Multiple Entry-Point Functions
When your end goal is to generate fixed-point C/C++ library functions, generating a single C/C++ library for more than one entry-point MATLAB® function allows you to:
Create C/C++ libraries containing multiple, compiled MATLAB files to integrate with larger C/C++ applications. Generating C/C++ code requires a MATLAB Coder™ license.
Share code efficiently between library functions.
Communicate between library functions using shared memory.
If any of the entry-point functions in a project share memory (for example, persistent data), an error will occur. In this case, you should rewrite your code to avoid invoking functions with persistent data from multiple entry-points.
In this example, you convert two entry-point functions,
to fixed point.
In a local writable folder, create the functions
function y = ep1(u) %#codegen y = u; end
function y = ep2(u, v) %#codegen y = u + v; end
In the same folder, create a test file,
ep_tb.m, that calls both functions.
% test file for ep1 and ep2 u = 1:100; v = 5:104; z = ep1(u); y = ep2(v,z);
From the apps gallery, open the Fixed-Point Converter app.
To add the first entry-point function,
ep1, to the project, on the Select Source Files page, browse to the
ep1file, and click Open.
By default, the app uses the name of the first entry-point function as the name of the project.
Click Add Entry-Point Function and add the second entry-point function,
ep2. Click Next.
On the Define Input Types page, enter a test file that exercises your two entry-point functions. Browse to select the
ep_tbfile. Click Autodefine Input Types.
Click Next. The app generates an instrumented MEX function for your entry-point MATLAB function. On the Convert to Fixed-Point page, click Simulate to simulate the entry-point functions, gather range information, and get proposed data types.
The entry-point functions
ep2convert to fixed point. The Output Files pane lists the generated fixed-point and wrapper files for both entry-point functions.
Click Next. The Finish Workflow page contains the project summary. The generated Fixed-Point Conversion Report contains the reports for both entry-point functions. The app stores the generated files in the subfolder