Main Content

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

  1. Change to the folder that contains the project file.

  2. Use the -tocode option of the coder 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 function conversion_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, the coder 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.

  1. 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

  2. Run the script:

    conversion_project_script

    The code generator creates a C static library with the name conversion_project_fixpt in the folder codegen\lib\conversion_project_fixpt. The variables cfg and ARGS 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.

  1. Make sure that the current folder contains the entry-point function conversion_project.m and the associated test bench file conversion_project_test.m.

  2. Run the script.

     conversion_project_script_fixpt

    The code generator creates conversion_project_fixpt.m in the folder codegen\conversion_project\fixpt. The variables cfg and ARGS appear in the base workspace.

See Also

| |

Topics