Spécification de l’entrée
Pour la génération de code, vous devez spécifier la taille et le type des variables en entrée de la fonction de point d’entrée. Vous pouvez spécifier les types d’entrée :
Dans votre code MATLAB en validant les arguments de la fonction de point d’entrée avec des blocs
arguments
. Si vous spécifiez les types d’entrée avec des blocsarguments
, vous pouvez également spécifier d’autres attributs de variables ; par exemple vous pouvez indiquer si les données en entrée sont complexes, creuses ou un GPU array, avec des validateurs tels quecoder.mustBeComplex
.À l’aide de l’application MATLAB Coder™.
À la ligne de commande en utilisant l’argument
-args
avec la commandecodegen
. Les types d’entrée spécifiés à la ligne de commande avec l’argument-args
peuvent être préconfigurés aveccoderTypeEditor
ou avec des fonctions commecoder.typeof
.Dans votre code MATLAB en effectuant un préconditionnement avec des instructions
assert
.
Applications
MATLAB Coder | Générer du code C ou une fonction MEX à partir de code MATLAB |
Fonctions
Classes
Objets
coder.OutputType | Output type from an entry-point function to specify as an input type |
Rubriques
Fondamentaux de la spécification de l’entrée
- 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.
Spécifier les types d’entrée dans le code MATLAB
- 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.
Spécifier les types d’entrée avec l’application MATLAB Coder
- 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.
Spécifier les types d’entrée à la ligne de commande
- 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.
Résolution des problèmes
- 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.