Specifiche di input
Per la generazione di codice, è necessario specificare le grandezze e i tipi di variabili di input per la funzione del punto di ingresso. È possibile specificare i tipi di input come segue:
Nel codice MATLAB, eseguendo la validazione degli argomenti della funzione del punto di ingresso utilizzando i blocchi
arguments
. Se si specificano i tipi di input utilizzando i blocchiarguments
, è inoltre possibile specificare altri attributi delle variabili, tra cui la natura complessa, sparsa o come array GPU dei dati di input, utilizzando validatori comecoder.mustBeComplex
.Utilizzando l'app MATLAB Coder™.
Dalla riga di comando, utilizzando l'argomento
-args
nel comandocodegen
. I tipi di input specificati alla riga di comando utilizzando l'argomento-args
possono essere preconfigurati utilizzandocoderTypeEditor
o funzioni comecoder.typeof
.Nel codice MATLAB, eseguendo il precondizionamento utilizzando le dichiarazioni
assert
.
App
MATLAB Coder | Generare codice C o funzione MEX da codice MATLAB |
Funzioni
Classi
Oggetti
coder.OutputType | Output type from an entry-point function to specify as an input type |
Argomenti
Nozioni di base sulle specifiche di input
- Specify Types of Entry-Point Function Inputs
How and why to perform input-type specification.
Specifica dei tipi di input nel codice 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.
Specifica dei tipi di input utilizzando l'app 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.
Specifica dei tipi di input dalla riga di comando
- 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. - 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 Value Class Objects as Inputs
Specify that an entry-point input is an object of a value class. - 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 Input or Output Arguments to Entry-Point Functions
Control the number of input or output arguments in the generated code.
Risoluzione dei problemi
- 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.