함수 정의
고정소수점 가속화에 사용할 MATLAB® 함수를 만들 때 특별히 고려해야 할 사항이 있습니다. 이러한 고려 사항에는 varargin과 varargout, 재귀 함수, 익명 함수, 중첩 함수를 사용할 때의 특정 제한 사항이 포함됩니다. 코드 생성기는 MATLAB 재귀 함수의 코드를 생성하기 위해 컴파일타임 재귀 또는 런타임 재귀를 사용합니다. 코드 생성기는 효율적인 C/C++ 코드를 생성하기 위해 함수 특수화라고 하는 여러 버전의 함수를 생성하는 경우가 있습니다. 경우에 따라 coder.ignoreConst (MATLAB Coder)를 사용하여 코드 생성기에서 함수 특수화를 생성하지 못하게 할 수 있습니다. MEX 함수를 생성하는 동안 MATLAB 코드에 있는 특정 함수에 대한 코드 생성을 건너뛰고 대신 MATLAB 엔진을 사용하여 호출을 실행할 수 있습니다. 이렇게 하려면 coder.extrinsic 구문을 사용하십시오.
함수
coder.extrinsic | 함수를 외재적 함수로 선언하고 MATLAB에서 실행 |
coder.ignoreConst | 표현식의 상수 값을 사용한 함수 특수화 금지 |
coder.mustBeConst | Validate that value is a compile-time constant (R2023b 이후) |
coder.unroll | Unroll for-loop by making a copy of
the loop body for each loop iteration |
coder.sameSizeBinaryOp | Apply element-wise binary operations without implicit expansion (R2021b 이후) |
coder.noImplicitExpansionInFunction | Disable implicit expansion within the specified function in the generated code (R2021b 이후) |
coder.read | Read data files at run time in generated code (R2023a 이후) |
coder.write | Create data files that the generated code reads at run time (R2023a 이후) |
문제 해결
오류 해결: 배열 크기가 호환되지 않습니다 (MATLAB Coder)
코드 생성 중에 발생하는 크기 비호환성 오류를 해결합니다.
가변 크기 데이터 오류의 진단 및 수정 (MATLAB Coder)
크기 불일치 및 상한 감지 오류를 해결합니다.
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.