Input Specification
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 usingarguments
blocks, you can also specify other variable attributes, including whether the input data is complex, sparse, or a GPU array, using validators such ascoder.mustBeComplex
.Using the MATLAB Coder™ app.
At the command line, using the
-args
argument to thecodegen
command. Input types specified at the command line using the-args
argument can be pre-configured using thecoderTypeEditor
or functions such ascoder.typeof
.In your MATLAB code, by performing preconditioning using
assert
statements.
Apps
MATLAB Coder | Generate C code or MEX function from MATLAB code |
Functions
Classes
Objects
coder.OutputType | Output type from an entry-point function to specify as an input type |
Topics
Input Specification Basics
- Specify Types of Entry-Point Function Inputs
How and why to perform input-type specification. - Specify Number of Input or Output Arguments to Entry-Point Functions
Control the number of input or output arguments in the generated code. - Specify Value Class Objects as Inputs
Specify that an entry-point input is an object of a value class.
Specify Input Types in MATLAB Code
- Use Function Argument Validation to Specify Entry-Point Input Types
Specify the types of the entry-point function inputs using anarguments
block. - Specify Input Types Using assert Statements in MATLAB Code
Specify the types of entry-point function inputs by using theassert
function.
Specify Input Types Using MATLAB Coder App
- Define Types of Entry-Point Inputs by Using the MATLAB Coder App
Specify the types of entry-point function inputs using the MATLAB Coder app. - Define Global Variables in the MATLAB Coder App
Use the MATLAB Coder app to specify the types and initial values of global variables that your MATLAB code uses.
Specify Input Types at the Command Line
- Specify Input Types at the Command Line
Specify entry-point function input type by using the-args
option. - Create and Edit Input Types by Using the Coder Type Editor
Define and editcoder.Type
objects interactively. - Pass an Entry-Point Function Output as an Input
Simplify input type specification for multiple entry-point functions. - Specify Cell Array Inputs at the Command Line
Provide an example cell array, define a cell array type, or specify a cell array constant input. - Specify Global Cell Arrays at the Command Line
Specify global cell array inputs with the-globals
option. - Specify String Scalar Inputs at the Command Line
Specify string scalar inputs at the command line.
Troubleshooting
- Resolve Issue: Using arguments Blocks to Specify Cell or Structure Entry-Point Input Types is Not Supported
Troubleshoot code generation error if cells or structs are used for input-type specification in the arguments block of an entry-point function.