coder - Open MATLAB
Coder app - MATLAB ([original](http://www.mathworks.com/help/coder/ref/coder.html)) ([raw](?raw))
Syntax
Description
coder
or matlabcoder
opens the MATLAB® Coder™ app. To create a new project, in the Create MATLAB Coder Project dialog box, give the new project a name and select a location. To open an existing project, clickOpen and navigate to the project file.
When the app creates a project, the app enables Embedded Coder® features if the Embedded Coder product is installed. When Embedded Coder features are enabled, code generation requires an Embedded Coder license. To disable Embedded Coder features, open the MEX Code Generation Settings or Standalone Code Generation Settings dialog box. On the Advanced pane, clear the Use Embedded Coder features check box.
coder [projectname](#bt261ix-1-projectname)
opens projectprojectname.coderprj
in the MATLAB Coder app.
coder -open [projectname](#bt261ix-1-projectname)
opens projectprojectname.coderprj
in the MATLAB Coder app.
coder -build [projectname](#bt261ix-1-projectname)
builds the existing project projectname.coderprj
.
coder -new [projectname](#bt261ix-1-projectname)
opens the MATLAB Coder app and creates a project named projectname.coderprj
.
If the app finds a function with the same name as the projectname
in the working directory, the app adds this function to projectname
as an entry-point function.
If the Embedded Coder product is installed, the app creates a new project with Embedded Coder features enabled. To disable Embedded Coder features, open the MEX Code Generation Settings or Standalone Code Generation Settings dialog box. On the Advanced pane, clear the Use Embedded Coder features check box.
coder -ecoder false -new [projectname](#bt261ix-1-projectname)
opens theMATLAB Coder app and creates a project named projectname.coderprj
. The app creates the project with Embedded Coder features disabled even if the Embedded Coder product is installed.
coder -tocode [projectname](#bt261ix-1-projectname) -script [scriptname](#bt261ix-1-scriptname)
converts the existing project named projectname.coderprj
to the equivalent script of MATLAB commands. The script is named scriptname
.
- If
scriptname
exists,coder
overwrites it. - The script reproduces the project build configuration in a configuration object and builds the project. The script:
- Creates a configuration object named
cfg
. - Defines the variable
inputTypes
for function input types. - Defines the variable
globalVariables
for global data initial values. - Runs the
codegen
command. When you run the script, the entry-point functions that are arguments tocodegen
must be on the search path.
- Creates a configuration object named
cfg
,inputTypes
, andglobalVariables
appear in the base workspace only after you run the script.
coder -tocode [projectname](#bt261ix-1-projectname)
converts the existing project named projectname.coderprj
to the equivalent script of MATLAB commands. It writes the script to the Command Window.
coder -toconfig [projectname](#bt261ix-1-projectname)
exports the code configuration settings stored in the MATLAB Coder project file to a code configuration object. Executing this command returns a code configuration object corresponding to projectname
. For more information on which code configuration object is returned for different project file settings, see Share Build Configuration Settings.
[cfg](#mw%5F78d5bbb9-cc12-4d94-8dfc-8c2f1aa380db) = coder("-toconfig","[projectname](#bt261ix-1-projectname)")
returns a configuration object that contains the code configuration settings stored in aMATLAB Coder project file. Executing this command returns a code configuration objectcfg
corresponding to projectname
. For more information on which code configuration object is returned for different project file settings, see Share Build Configuration Settings.
Examples
Open the MATLAB Coder app using the existing MATLAB Coder project named my_coder_project
.
coder -open my_coder_project
Build the MATLAB Coder project named my_coder_project
.
coder -build my_coder_project
Open the MATLAB Coder app and create a project named my_coder_project
.
coder -new my_coder_project
Convert the MATLAB Coder project named my_coder_project.coderprj
to the MATLAB script named myscript.m
.
coder -tocode my_coder_project -script my_script.m
Create code configuration object cfg
corresponding to the configuration settings stored in my_coder_project
.
cfg = coder("-toconfig","my_coder_project");
Input Arguments
Name of MATLAB Coder project 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 -tocode
option with the -script
option. The script name must not contain spaces.
Output Arguments
Code configuration object that contains the configuration settings stored in aMATLAB Coder project file.
Tips
- If you are sharing an Embedded Coder license, use
coder -ecoder false -new projectname
to 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. - Before creating a project or opening an existing project, the app closes any currently open MATLAB Coder project.
- If your installation does not include the Embedded Coder product, Embedded Coder settings are not displayed. 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.
Alternatives
- On the Apps tab, in the Code Generation section, click MATLAB Coder.
- Use the codegen function to generate code at the command line.
Version History
Introduced in R2011a
The coder
function creates code generation project files with a.coderprj
extension, instead of with a .prj
extension. If you open a MATLAB Coder project file created before R2025a by using the coder
function, the code generator saves a copy of the PRJ file to a CODERPRJ file. If you save changes to your project, the changes are saved to the CODERPRJ file, not the PRJ file. In some cases, the app is unable to migrate parameters that are specific to a hardware support package from the PRJ file to the CODERPRJ file. If you use a hardware support package, verify that the configuration parameters are correct before generating code.