이 번역 페이지는 최신 내용을 담고 있지 않습니다. 최신 내용을 영문으로 보려면 여기를 클릭하십시오.
객체 인덱싱 사용자 지정하기
객체에 대한 인덱스 참조와 값 할당 동작을 사용자 지정합니다. 사용자 정의 클래스는 내장 MATLAB® 클래스와 동일한 인덱싱 동작을 가지지만, 하나 이상의 슈퍼클래스에서 상속하는 방식으로 이 동작을 수정할 수 있습니다.
모듈식 인덱싱 mixin 클래스(R2021b 이후)를 사용하여 개별적으로 인덱싱 연산을 사용자 지정할 수 있습니다. 예를 들어, matlab.mixin.indexing.RedefinesParen
에서 상속하면 추가 코드를 작성할 필요 없이 괄호 인덱싱을 사용자 지정하면서 동시에 점과 중괄호 인덱싱에 디폴트 MATLAB 동작을 사용할 수 있습니다.
클래스에 subsref
함수와 subsasgn
함수를 오버로드할 수도 있지만, 이 기법에서는 단 하나의 동작만 사용자 지정하려 해도 괄호, 점, 중괄호 인덱싱을 오버로드해야 합니다. 가능하다면 항상 모듈식 인덱싱 클래스를 사용하는 것이 좋습니다.
클래스
matlab.mixin.indexing.RedefinesParen | Customize class indexing operations that use parentheses (R2021b 이후) |
matlab.mixin.indexing.RedefinesDot | Customize class indexing operations that use dots (R2021b 이후) |
matlab.mixin.indexing.RedefinesBrace | Customize class indexing operations that use braces (R2021b 이후) |
matlab.indexing.IndexingOperation | Type of customized indexing operation and referenced indices (R2021b 이후) |
matlab.mixin.Scalar | Enforce scalar behavior for class instances (R2021b 이후) |
matlab.mixin.indexing.ForbidsPublicDotMethodCall | Disallow calling public methods using dot notation (R2021b 이후) |
matlab.mixin.indexing.OverridesPublicDotMethodCall | Calling public methods with dot notation invokes overloaded dot indexing (R2021b 이후) |
함수
도움말 항목
- 객체 인덱싱 사용자 지정하기
MATLAB 클래스는 기본적으로 객체 배열 인덱싱을 지원합니다.
- Customize Parentheses Indexing for Mapping Class
This example shows how to customize parentheses indexing for a mapping class.
- Forward Indexing Operations
Forward additional levels of indexing after customized indexing operations.
- Overload end for Classes
Overload
end
for customized indexing applications. - 인덱스 표현식 내 객체
인덱싱 표현식에서 인덱스로 사용될 수 있는 객체를 설계할 수 있습니다.
- Code Patterns for subsref and subsasgn Methods
There are code patterns useful for modifying object indexing.