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 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
- Specify Types of Entry-Point Inputs Using the App
Specify the types of entry-point function inputs using the MATLAB Coder app. - Automatically Define Input Types by Using the App
Provide a test that calls the entry-point functions with representative data. - Define Input Parameter by Example by Using the App
Specify properties of an input parameter by providing an example value. - Specify Global Variable Type and Initial Value Using the App
Specify type and initial value of global variables that your MATLAB code uses. - Specify Objects as Inputs in the MATLAB Coder App
Define the type of a value class input from a test file or an example input. - Make Dimensions Variable-Size When They Meet Size Threshold
Specify and apply rules for making dimensions variable-size.
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. - Edit and Represent Coder Type Objects and Properties
Command line representation of coder type objects. - 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 Objects as Inputs at the Command Line
Specify that an entry-point input is an object of a value class by using thecodegen
-args
option. - Pass an Entry-Point Function Output as an Input
Simplify input type specification for multiple entry-point functions. - Specify String Scalar Inputs at the Command Line
Specify string scalar inputs at the command line. - Specify Number of Entry-Point Function Input or Output Arguments to Generate
Control the number of arguments in generated entry-point functions.
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.