주요 콘텐츠

가변 크기 데이터

정의 및 코드 생성 시 차이점

코드 생성 시, 코드 생성기는 스칼라, 벡터, 행렬을 포함해 배열을 고정 크기 또는 가변 크기로 식별합니다.

  • 코드 생성기가 배열의 크기를 확인할 수 없거나 배열의 크기가 변하는 경우 코드 생성기는 그 배열을 가변 크기로 지정합니다.

  • 코드 생성기는 배열의 크기가 변하지 않는다고 확인되면 그 배열을 고정 크기로 지정합니다.

코드 생성기가 고정 크기 배열과 가변 크기 배열을 처리하는 방법을 이해하면 코드 생성 시 오류를 진단하고 수정하는 데 도움이 될 수 있습니다. 사용자의 애플리케이션이 가변 크기 배열을 필요로 하지 않는 경우, 가변 크기 설정과 동적 메모리 할당을 미세 조정하여 생성 코드의 성능을 개선할 수도 있습니다.

블록

MATLAB FunctionSimulink 모델에 MATLAB 코드 포함
MATLAB SystemInclude System object in model

함수

coder.areUnboundedVariableSizedArraysSupportedCheck if current configuration settings allow unbounded variable-size arrays (R2024a 이후)
coder.varsizeResolve size incompatibility errors and declare upper bounds

가변 크기 기본 사항

Generate Code for Variable-Size Arrays (MATLAB Coder)

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

가변 크기의 MATLAB Function 블록 변수 선언하기

시뮬레이션 도중 MATLAB Function 블록에 정의된 변수의 크기 변경을 허용합니다.

Unbounded Variable-Size Signals

Model unknown size data using dynamic arrays.

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.

동적 메모리 할당

Use Dynamic Memory Allocation for Variable-Size Arrays in a MATLAB Function Block

Generate C/C++ code that uses dynamic memory allocation.

Control Memory Allocation for Variable-Size Arrays in a MATLAB Function Block

Disable dynamic memory allocation or specify a dynamic memory allocation threshold for MATLAB Function blocks.

문제 해결

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

추천 예제