Documentation

coder

OpenMATLABCoderapp

Syntax

coder
coder projectname
coder -open projectname
coder -build projectname
coder -new projectname
coder -ecoder false -new projectname
coder -tocode projectname -script scriptname
coder -tocode projectname

Description

coderopens theMATLAB®Coder™app. To create a project, on theSelect Source Filespage, provide the entry-point file names. The app creates a project with a default name that is the name of the first entry-point file. To open an existing project, on the app toolbar, click, and then clickOpen existing project.

If the Embedded Coder®product is installed, when the app creates a project, it enables Embedded Coder features. When Embedded Coder features are enabled, code generation requires an Embedded Coder license. To disable Embedded Coder features, in the project build settings, on theAll Settingstab, underAdvanced, setUse Embedded Coder featurestoNo.

coderprojectnameopens theMATLAB Coderapp using the existing project namedprojectname.prj.

example

coder -openprojectnameopens theMATLAB Coderapp using the existing project namedprojectname.prj.

example

coder -buildprojectnamebuilds the existing project namedprojectname.prj.

example

coder -newprojectnameopens theMATLAB Coderapp creating a project namedprojectname.prj. If the Embedded Coder product is installed, the app creates the project with Embedded Coder features enabled. To disable these features, in the project build settings, on theAll Settingstab, underAdvanced, setUse Embedded Coder featurestoNo.

coder -ecoder false -newprojectnameopens theMATLAB Coderapp creating a project namedprojectname.prj. The app creates the project with Embedded Coder features disabled even if the Embedded Coder product is installed.

example

coder -tocodeprojectname-scriptscriptnameconverts the existing project namedprojectname.prjto the equivalent script of MATLAB commands. The script is namedscriptname.

  • Ifscriptnameexists,coderoverwrites it.

  • 脚本繁殖项目构建configuration in a configuration object and builds the project. The script:

    • Creates a configuration object namedcfg.

    • Defines the variableARGSfor function input types.

    • Defines the variableGLOBALSfor global data initial values.

    • Runs thecodegencommand. When you run the script, the entry-point functions that are arguments tocodegenmust be on the search path.

  • cfg,ARGS, andGLOBALSappear in the base workspace only after you run the script.

If the project includes automated fixed-point conversion,codergenerates two scripts:

  • A scriptscriptnamethat contains the MATLAB commands to:

    • Create a code configuration object that has the same settings as the project.

    • Run thecodegencommand to convert the fixed-point MATLAB function to a fixed-point C function.

  • A script whose file name is a concatenation of the name specified byscriptnameand the generated fixed-point file name suffix specified by the project file. Ifscriptnamespecifies a file extension, the script file name includes the file extension. For example, ifscriptnameismyscript.m和足量x is the default value_fixpt, the script name ismyscript_fixpt.m.

    This script contains the MATLAB commands to:

    • Create a floating-point to fixed-point conversion configuration object that has the same fixed-point conversion settings as the project.

    • Run thecodegencommand to convert the floating-point MATLAB function to a fixed-point MATLAB function.

For a project that includes fixed-point conversion, before converting the project to scripts, complete theTest Numericsstep of the fixed-point conversion process.

coder -tocodeprojectnameconverts the existing project namedprojectname.prjto the equivalent script of MATLAB commands. It writes the script to the Command Window.

Examples

collapse all

Open theMATLAB Coderapp using the existingMATLAB Coderproject namedmy_coder_project.

coder-openmy_coder_project

Build theMATLAB Coderproject namedmy_coder_project.

coder-buildmy_coder_project

Open theMATLAB Coderapp and create a project namedmy_coder_project.

coder-newmy_coder_project

Convert theMATLAB Coderproject namedmy_coder_project.prjto the MATLAB script namedmyscript.m.

coder-tocodemy_coder_project-scriptmy_script.m

Input Arguments

collapse all

Name ofMATLAB Coderproject that you want to create, open, or build. The project name must not contain spaces.

Name of script that you want to create when using the-tocodeoption with the-scriptoption. The script name must not contain spaces.

Tips

  • If you are sharing an Embedded Coder license, usecoder -ecoder false -new projectnameto create a project that does not require this license. If the Embedded Coder product is installed, the app creates the project with Embedded Coder features disabled. When these features are disabled, code generation does not require an Embedded Coder license. To enable Embedded Coder features, in the project build settings, on theAll Settingstab, underAdvanced, setUse Embedded Coder featurestoYes.

  • Creating a project or opening an existing project causes otherMATLAB Coderor Fixed-Point Converter projects to close.

  • If your installation does not include the Embedded Coder product, the Embedded Coder settings do not show. However, values for these settings are saved in the project file. If you open the project in an installation that includes the Embedded Coder product, you see these settings.

  • A Fixed-Point Converter project opens in the Fixed-Point Converter app. To convert the project to aMATLAB Coderproject, in the Fixed-Point Converter app:

    1. Clickand selectReopen project as.

    2. SelectMATLAB Coder.

Alternatives

  • On theAppstab, in theCode Generationsection, clickMATLAB Coder.

  • Use thecodegenfunction to generate code at the command line.

Introduced in R2011a

Was this topic helpful?