Main Content

이 페이지는 기계 번역을 사용하여 번역되었습니다. 영어 원문을 보려면 여기를 클릭하십시오.

함수 정의

코드 생성을 위해 함수 정의 및 호출

MATLAB Function 블록에서 사용할 MATLAB® 함수를 만들 때 특별히 고려해야 할 사항이 있습니다. 이러한 고려 사항에는 vararginvarargout, 재귀 함수, 익명 함수, 중첩 함수를 사용할 때의 특정 제한 사항이 포함됩니다. 코드 생성기는 MATLAB 재귀 함수의 코드를 생성하기 위해 컴파일타임 재귀 또는 런타임 재귀를 사용합니다. 코드 생성기는 효율적인 C/C++ 코드를 생성하기 위해 함수 특수화라고 하는 여러 버전의 함수를 생성하는 경우가 있습니다. 경우에 따라 coder.ignoreConstcoder.ignoreSize를 사용하여 코드 생성기에서 함수 특수화를 생성하지 못하게 할 수 있습니다. MATLAB 코드에서 특정 함수에 대한 코드 생성을 건너뛰고 대신 MATLAB 엔진을 사용하여 호출을 실행할 수 있습니다. 이렇게 하려면 coder.extrinsic 구문을 사용하십시오.

블록

MATLAB FunctionInclude MATLAB code in Simulink models
MATLAB SystemInclude System object in model

함수

coder.extrinsic함수를 외재적 함수로 선언하고 MATLAB에서 실행
coder.ignoreSizePrevent code generator from creating function specializations for constant-size expressions (R2019b 이후)
coder.ignoreConst표현식의 상수 값을 사용한 함수 특수화 금지
coder.mustBeConstValidate that value is a compile-time constant (R2023b 이후)
coder.unrollUnroll for-loop by making a copy of the loop body for each loop iteration
coder.sameSizeBinaryOpApply element-wise binary operations without implicit expansion (R2021b 이후)
coder.noImplicitExpansionInFunctionDisable implicit expansion within the specified function in the generated code (R2021b 이후)
coder.readRead data files at run time in generated code (R2023a 이후)
coder.writeCreate data files that the generated code reads at run time (R2023a 이후)

도움말 항목

문제 해결

for 루프에서 varargin 또는 varargout에 대한 인덱스가 상수가 아닌 경우

코드 생성기가 varargin 또는 varargout에 대한 인덱스 값을 확인할 수 없는 경우 루프 풀기를 강제로 실행합니다.

Avoid Duplicate Functions in Generated Code

Reduce the occurrence of duplicate functions in the generated code.

Output Variable Must Be Assigned Before Run-Time Recursive Call

Troubleshoot output variable assignment for run-time recursion.

Compile-Time Recursion Limit Reached

Troubleshoot compile-time recursion limit error.

Resolve Error: Size Mismatches

Troubleshoot size mismatch errors that occur during code generation.