Main Content

coder

OpenMATLABCoderapp

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.

前女友ample

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

前女友ample

coder -buildprojectnamebuilds the existing project namedprojectname.prj.

前女友ample

coder -newprojectnameopens theMATLAB Coder应用程序创建一个项目projectname.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 Coder应用程序创建一个项目projectname.prj. The app creates the project with Embedded Coder features disabled even if the Embedded Coder product is installed.

前女友ample

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

  • Ifscriptname前女友ists,coderoverwrites it.

  • The script reproduces the project build 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.mand the suffix 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.

coder -toconfigprojectname前女友ports the code configuration settings stored in aMATLAB Coderproject file to a code configuration object. Executing this command returns a code configuration object corresponding toprojectname. For more information on which code configuration object is returned for different project file settings, seeShare Build Configuration Settings.

前女友ample

cfg= coder('-toconfig','projectname')returns a configuration object that contains the code configuration settings stored in aMATLAB Coderproject file. Executing this command returns a code configuration objectcfgcorresponding toprojectname. For more information on which code configuration object is returned for different project file settings, seeShare Build Configuration Settings.

coder -typeEditoropens an empty Coder Type Editor dialog. If a dialog is already open, this command brings it to the front of the screen.

SeeCreate and Edit Input Types by Using the Coder Type Editor.

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

Define a MATLAB function,myadd, that returns the sum of two values.

functiony = myadd(u,v)%#codegeny = u + v;end

Create aMATLAB Coderprojectmyadd.prj:

  • Open theMATLAB Coderapp. Specifymyaddas the entry point function.

  • On theDefine Inputs Types页面,specifyuandvas double scalars.

  • On theGenerate Codepage, setBuild TypetoMEX. Leave other project file settings with their default values.

At the MATLAB command line, run this command:

cfg = coder('-toconfig','myadd.prj');

The code generator creates acoder.MexCodeConfigobjectcfgthat contains the code configuration settings stored inmyadd.prj.

Inspect the properties ofcfg.

cfg =描述:'类MexCodeConfig:墨西哥人进行guration objects with C code.' Name: 'MexCodeConfig' -------------------------------- Report ------------------------------- GenerateReport: true LaunchReport: false ReportInfoVarName: '' ReportPotentialDifferences: false ------------------------------- Debugging ----------------------------- EchoExpressions: true EnableDebugging: false EnableMexProfiling: false ---------------------------- Code Generation -------------------------- ConstantInputs: 'CheckValues' EnableJIT: false FilePartitionMethod: 'MapMFileToCFile' GenCodeOnly: false HighlightPotentialRowMajorIssues: true PostCodeGenCommand: '' PreserveArrayDimensions: false RowMajor: false TargetLang: 'C' ------------------------ Language And Semantics ----------------------- CompileTimeRecursionLimit: 50 ConstantFoldingTimeout: 40000 EnableDynamicMemoryAllocation: true DynamicMemoryAllocationThreshold: 65536 EnableAutoExtrinsicCalls: true EnableRuntimeRecursion: true EnableVariableSizing: true ExtrinsicCalls: true GlobalDataSyncMethod: 'SyncAlways' InitFltsAndDblsToZero: true PreserveVariableNames: 'None' SaturateOnIntegerOverflow: true ------------------------- C++ Language Features ----------------------- CppNamespace: '' ----------------- Safety (disable for faster execution) --------------- IntegrityChecks: true ResponsivenessChecks: true ---------------- Function Inlining and Stack Allocation --------------- InlineStackLimit: 4000 InlineThreshold: 10 InlineThresholdMax: 200 StackUsageMax: 200000 ----------------------------- Optimizations --------------------------- EnableMemcpy: true EnableOpenMP: true MemcpyThreshold: 64 ------------------------------- Comments ------------------------------ GenerateComments: true MATLABSourceComments: false ------------------------------ Custom Code ---------------------------- CustomHeaderCode: '' CustomInclude: '' CustomInitializer: '' CustomLibrary: '' CustomSource: '' CustomSourceCode: '' CustomTerminator: '' ReservedNameArray: ''

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.

Output Arguments

collapse all

Code configuration object that contains the configuration settings stored in aMATLAB Coderproject file.

Limitations

  • Thecoderfunction is not supported inMATLAB Online™.

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.

Version History

Introduced in R2011a