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
-tocodeoption of thecodercommand to convert the project to the scripts. Use the-scriptoption to specify the file name for the scripts.coder -tocode conversion_project.prj -script conversion_project_script.m
The
codercommand generates two scripts in the current folder:conversion_project_script.mcontains the MATLAB commands to:Create a code generation configuration object that has the same settings as the project.
Run the
codegencommand to convert the fixed-point MATLAB functionconversion_project_fixptto a fixed-point C function.
The
codercommand overwrites existing files that have the same names as the generated scripts. If you omit the-scriptoption, thecodercommand 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.mis on the search path.addpath c:\coder\conversion_project\codegen\conversion_project\fixptRun the script:
conversion_project_script
The code generator creates a C static library with the name
conversion_project_fixptin the foldercodegen\lib\conversion_project_fixpt. The variablescfgandARGSappear 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.mand the associated test bench fileconversion_project_test.m.Run the script.
conversion_project_script_fixpt
The code generator creates
conversion_project_fixpt.min the foldercodegen\conversion_project\fixpt. The variablescfgandARGSappear in the base workspace.
See Also
coder | codegen | coder.FixPtConfig