Dati di dimensione variabile
Durante la generazione di codice, il generatore di codice identifica gli array, inclusi scalari, vettori e matrici, come di dimensione fissa o variabile.
Il generatore di codice considera un array di dimensione variabile se non è in grado di determinarne la dimensione o se la dimensione dell'array cambia.
Il generatore di codice designa un array come di dimensione fissa se è in grado di determinare che la dimensione dell'array non cambia.
Comprendere come il generatore di codice gestisce gli array di dimensione fissa e variabile può essere utile per diagnosticare e correggere gli errori durante la generazione di codice. Se l'applicazione non richiede array di dimensione variabile, è inoltre possibile sincronizzare con precisione il dimensionamento delle variabili e l'allocazione dinamica della memoria per migliorare potenzialmente le prestazioni del codice generato.
Blocchi
| MATLAB Function | Include MATLAB code in Simulink models |
| MATLAB System | Include System object in model |
Funzioni
coder.areUnboundedVariableSizedArraysSupported | Check if current configuration settings allow unbounded variable-size arrays (Da R2024a) |
coder.varsize | Resolve size incompatibility errors and declare upper bounds |
Risoluzione dei problemi
Resolve Error: Arrays Have Incompatible Sizes (MATLAB Coder)
Troubleshoot size incompatibility errors that occur during code generation.
Resolve Error: Fixed Size on the Left Side but Variable Size on the Right (MATLAB Coder)
Troubleshoot errors when assigning variable-size arrays to fixed-size arrays.
Resolve Error: coder.varsize Not Supported for Strings (MATLAB Coder)
Troubleshoot code generation error when using coder.varsize
with string variables.
Resolve Error: coder.varsize Not Supported for Class Properties (MATLAB Coder)
Troubleshoot code generation error when using coder.varsize
with properties of a MATLAB class.
Resolve Error: Unable to Produce Column Vector from Scalar (MATLAB Coder)
Troubleshoot error when an input argument that is a variable-length column vector at code generation time is a scalar at run time.
Resolve Error: Incorrect Size for Expression (MATLAB Coder)
Troubleshoot MEX function error when the size of an array at run time is incompatible with the size of the array in the generated code.
