Convert Fixed-Point Conversion Project to MATLAB Scripts
You can convert an existing MATLAB®
Coder™ project to MATLAB scripts when the project includes automated fixed-point conversion. You
can use the -tocode
option of the coder
command to
create a pair of scripts for fixed-point conversion and fixed-point code generation. You
can use the scripts to repeat the project workflow in a command-line workflow. Before
you convert the project to the scripts, you must complete the Test
step of the fixed-point conversion process.
Generate Scripts
Change to the folder that contains the project file.
Use the
-tocode
option of thecoder
command to convert the project to the scripts. Use the-script
option to specify the file name for the scripts.coder -tocode conversion_project.prj -script conversion_project_script.m
The
coder
command generates two scripts in the current folder:conversion_project_script.m
contains the MATLAB commands to:Create a code generation configuration object that has the same settings as the project.
Run the
codegen
command to convert the fixed-point MATLAB functionconversion_project_fixpt
to a fixed-point C function.
The
coder
command overwrites existing files that have the same names as the generated scripts. If you omit the-script
option, thecoder
command writes the scripts to the Command Window.
Run Script That Generates Fixed-Point C Code
To run the script that generates fixed-point C code from fixed-point MATLAB code, the fixed-point MATLAB function specified in the script must be available.
Make sure that the fixed-point MATLAB function
conversion_project_fixpt.m
is on the search path.addpath c:\coder\conversion_project\codegen\conversion_project\fixpt
Run the script:
conversion_project_script
The code generator creates a C static library with the name
conversion_project_fixpt
in the foldercodegen\lib\conversion_project_fixpt
. The variablescfg
andARGS
appear in the base workspace.
Run Script That Generates Fixed-Point MATLAB Code
If you do not have the fixed-point MATLAB function, or if you want to regenerate it, use the script that generates the fixed-point MATLAB function from the floating-point MATLAB function.
Make sure that the current folder contains the entry-point function
conversion_project.m
and the associated test bench fileconversion_project_test.m
.Run the script.
conversion_project_script_fixpt
The code generator creates
conversion_project_fixpt.m
in the foldercodegen\conversion_project\fixpt
. The variablescfg
andARGS
appear in the base workspace.
See Also
coder
| codegen
| coder.FixPtConfig