MATLAB 코드 분석
C/C++ 코드가 생성되지 않도록 하는 MATLAB® 코드의 문제 식별 및 수정
MATLAB 코드에서 C/C++ 코드를 성공적으로 생성할 수 있을지 여부는 코드 생성 규칙 및 제한 사항을 준수하는지에 따라 결정됩니다. 예를 들어, MATLAB 코드는 코드 생성을 지원하는 MATLAB 함수와 툴박스 함수만 사용해야 합니다. C/C++ 코드 생성 전에 MATLAB 코드 관련 문제를 식별하고 수정하기 위해 코드 분석기와 코드 생성 준비 툴을 사용할 수 있습니다. MATLAB 코드가 예상대로 작동하는 생성 코드를 생성하는지 확인하려면 MATLAB 환경에서 실행할 수 있고 테스트할 수 있는 MEX 함수를 생성해 실행하십시오.
함수
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 (R2022a 이후) |
속성
coder.CallSite Properties | Information about a function call site in your MATLAB code (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 (R2022a 이후) |
도움말 항목
코드 생성 준비하기
- 진입점 함수 식별하기와 MATLAB 코드 검사하기
코드를 생성하기 전에 진입점 함수를 식별하고 MATLAB 코드에 오류가 있는지 검사합니다. - 코드 생성 준비 툴
코드 생성 준비 툴은 MATLAB 코드에 코드 생성에서 지원하지 않는 기능과 함수가 있지 않은지 검사합니다.
디버그
- 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.
문제 해결하기
- 오류 해결: 코드 생성 시 함수가 지원되지 않음
지원되지 않는 MATLAB 함수의 코드 생성 실패 문제를 해결합니다. - 문제 해결: 변수를 사용하기 전에 완전히 정의해야 합니다
구조체 필드와 클래스 속성을 포함하여 변수를 사용하기 전에 변수가 정의되지 않은 경우에 발생하는 코드 생성 오류를 해결합니다. - Resolve Issue: Cell Array Elements Must Be Fully Defined Before Use
Troubleshoot code generation errors when cell array elements are not defined before use.