Main Content

Input Specification

Specify properties of MATLAB® function input variables to enable code generation

For code generation, you must specify the sizes and types of input variables to the entry-point function. You can specify input types:

  • In your MATLAB code, by performing function argument validation in the entry-point function using arguments blocks. If you specify input types using arguments blocks, you can also specify other variable attributes, including whether the input data is complex, sparse, or a GPU array, using validators such as coder.mustBeComplex.

  • Using the MATLAB Coder™ app.

  • At the command line, using the -args argument to the codegen command. Input types specified at the command line using the -args argument can be pre-configured using the coderTypeEditor or functions such as coder.typeof.

  • In your MATLAB code, by performing preconditioning using assert statements.

Apps

MATLAB CoderGenerate C code or MEX function from MATLAB code

Functions

expand all

codegenGenerate C/C++ code from MATLAB code
coder.getArgTypesDetermine types of function input arguments by executing test file
coder.newtypeCreate coder.Type object to represent type of an entry-point function input
coder.resizeResize coder.Type object
coder.typeofCreate coder.Type object to represent the type of an entry-point function input
coderTypeEditorLaunch the Coder Type Editor dialog box (Since R2020a)
argumentsDeclare function argument validation
coder.mustBeComplexValidate that value lies on the complex plane (Since R2023b)
coder.specifyAsGPUSpecify that value is a GPU input to an entry-point function for GPU code generation (Since R2023b)
coder.varsizeResolve size mismatch errors and declare upper bounds
mustBeAValidate that value comes from one of specified classes (Since R2020b)
mustBeNonsparseValidate that value is nonsparse
mustBeRealValidate that value is real
mustBeSparseValidate that value is sparse (Since R2023b)
assertThrow error if condition false

Classes

expand all

coder.ArrayTypeRepresent set of MATLAB arrays acceptable for input specification
coder.CellTypeRepresent set of MATLAB cell arrays
coder.ClassTypeRepresent set of MATLAB classes acceptable for input specification
coder.ConstantSpecification of constant value for code generation
coder.EnumTypeRepresent set of MATLAB enumerations acceptable for input specification
coder.FiTypeRepresent set of MATLAB fixed-point arrays acceptable for input specification
coder.PrimitiveTypeRepresent set of logical, numeric, or character arrays acceptable for input specification
coder.StructTypeRepresent set of MATLAB structure arrays acceptable for input specification
coder.StringTypeRepresent set of MATLAB strings acceptable for input specification (Since R2022b)
coder.TypeRepresent set of MATLAB values acceptable for input specification

Objects

coder.OutputTypeOutput type from an entry-point function to specify as an input type

Topics

Input Specification Basics

Specify Input Types in MATLAB Code

Specify Input Types Using MATLAB Coder App

Specify Input Types at the Command Line

Troubleshooting