주요 콘텐츠

함수 정의

코드 가속화를 위한 정의 및 호출

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

함수

coder.extrinsic함수를 외재적 함수로 선언하고 MATLAB에서 실행
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 이후)

가변 크기 기본 사항

Generate Code for Variable-Size Arrays (MATLAB Coder)

Learn how the code generator defines and handles fixed- and variable-size data.

Code Generation for Arrays That Grow Via end+1 Indexing (MATLAB Coder)

Code generation considerations when you use (end+1) or {end+1} to grow an array.

Specify Upper Bounds for Variable-Size Arrays in Generated Code (MATLAB Coder)

To avoid dynamic memory allocation, specify upper bounds for variable-size arrays.

Incompatibilities with MATLAB in Variable-Size Support for Code Generation (MATLAB Coder)

Understand how the behavior of the generated code can differ from MATLAB as a result of variable-size data.

Generate Code for a MATLAB Function That Expands a Vector in a Loop (MATLAB Coder)

Generate C and C++ code for a function that uses variable-size data with and without dynamically allocated memory.

동적 메모리 할당

Control Dynamic Memory Allocation in Generated Code (MATLAB Coder)

Balance memory usage and performance by controlling dynamic memory allocation for fixed- and variable-size arrays.

Generate Code with Implicit Expansion Enabled (MATLAB Coder)

The code generator introduces modifications in the generated code to accomplish implicit expansion.

Optimize Implicit Expansion in Generated Code (MATLAB Coder)

Implicit expansion in the generated code is enabled by default.

Representation of Arrays in Generated Code (MATLAB Coder)

Understand how arrays are represented in the generated code.

Use Dynamically Allocated C Arrays in the Generated Function Interfaces (MATLAB Coder)

Understand and use dynamically allocated arrays from the generated C function interfaces.

Use Dynamically Allocated C++ Arrays in Generated Function Interfaces (MATLAB Coder)

Understand and use dynamically allocated arrays from the generated C++ function interfaces.

문제 해결

오류 해결: 배열 크기가 호환되지 않습니다 (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.