Analisi del codice MATLAB
Identificare e risolvere i problemi nel codice MATLAB® che impediscono la generazione di codice C/C++
La generazione riuscita di codice C/C++ da codice MATLAB dipende dalla conformità alle regole e alle limitazioni della generazione di codice. Ad esempio, il codice MATLAB deve utilizzare solo funzioni di MATLAB e funzioni della toolbox supportate per la generazione di codice. Per identificare e risolvere i problemi nel codice MATLAB prima della generazione di codice C/C++, è possibile utilizzare l'analizzatore di codice e lo strumento di predisposizione per la generazione di codice. Per verificare che il codice MATLAB produca codice generato che funziona come previsto, generare ed eseguire una funzione MEX, eseguibile e verificabile nell'ambiente di MATLAB.
Funzioni
coder.runTest | Run test replacing calls to MATLAB functions with calls to MEX functions |
coder.screener | Determine if function is suitable for code generation |
getLineColumn | Find locations of beginning and end of MATLAB code involved in code generation |
textReport | Export code generation readiness report to base workspace as a character vector (Da R2022a) |
Proprietà
| coder.CallSite Properties | Information about a function call site in your MATLAB code (Da R2022a) |
| coder.CodeFile Properties | Description of file containing text that is involved in code generation |
| coder.File Properties | Description of file without text that is involved in code generation |
| coder.Message Properties | Description of message produced during code generation readiness analysis or during code generation |
| coder.ScreenerInfo Properties | Code generation readiness information (Da R2022a) |
Argomenti
Preparazione per la generazione di codice
- Identify Entry-Point Functions and Check MATLAB Code
Identify entry-point functions and check MATLAB code for errors before code generation. - Code Generation Readiness Tool
The code generation readiness tool screens MATLAB code for features and functions that code generation does not support.
Debug
- Check for Issues in MATLAB Code Using MEX Functions
Use MEX functions to verify that the generated code provides the same functionality as the original MATLAB code. - Debugging Strategies
Choose a strategy for detecting and correcting code that is not suitable for code generation. - Debugging Generated MEX Code
Debug MEX code generated from your MATLAB code. - Debug Generated C/C++ Code
Debug standalone C/C++ code generated from your MATLAB code. - Profile MEX Functions by Using MATLAB Profiler
See execution times and code coverage for generated MEX functions in MATLAB Profiler.
Risoluzione dei problemi
- Risoluzione dell'errore: funzione non supportata per la generazione di codice
Risoluzione dei problemi di generazione di codice delle funzioni di MATLAB non supportate. - Resolve Issue: Variables Must Be Fully Defined Before Use
Troubleshoot code generation errors when variables, including structure fields and class properties, are not defined before use. - Resolve Issue: Cell Array Elements Must Be Fully Defined Before Use
Troubleshoot code generation errors when cell array elements are not defined before use.