Main Content

이 번역 페이지는 최신 내용을 담고 있지 않습니다. 최신 내용을 영문으로 보려면 여기를 클릭하십시오.

객체 인덱싱 사용자 지정하기

클래스에 대해 인덱스 참조와 값 할당 사용자 지정

객체에 대한 인덱스 참조와 값 할당 동작을 사용자 지정합니다. 사용자 정의 클래스는 내장 MATLAB® 클래스와 동일한 인덱싱 동작을 가지지만, 하나 이상의 슈퍼클래스에서 상속하는 방식으로 이 동작을 수정할 수 있습니다.

모듈식 인덱싱 mixin 클래스(R2021b 이후)를 사용하여 개별적으로 인덱싱 연산을 사용자 지정할 수 있습니다. 예를 들어, matlab.mixin.indexing.RedefinesParen에서 상속하면 추가 코드를 작성할 필요 없이 괄호 인덱싱을 사용자 지정하면서 동시에 점과 중괄호 인덱싱에 디폴트 MATLAB 동작을 사용할 수 있습니다.

클래스에 subsref 함수와 subsasgn 함수를 오버로드할 수도 있지만, 이 기법에서는 단 하나의 동작만 사용자 지정하려 해도 괄호, 점, 중괄호 인덱싱을 오버로드해야 합니다. 가능하다면 항상 모듈식 인덱싱 클래스를 사용하는 것이 좋습니다.

클래스

matlab.mixin.indexing.RedefinesParenCustomize class indexing operations that use parentheses (R2021b 이후)
matlab.mixin.indexing.RedefinesDotCustomize class indexing operations that use dots (R2021b 이후)
matlab.mixin.indexing.RedefinesBraceCustomize class indexing operations that use braces (R2021b 이후)
matlab.indexing.IndexingOperationType of customized indexing operation and referenced indices (R2021b 이후)
matlab.mixin.ScalarEnforce scalar behavior for class instances (R2021b 이후)
matlab.mixin.indexing.ForbidsPublicDotMethodCallDisallow calling public methods using dot notation (R2021b 이후)
matlab.mixin.indexing.OverridesPublicDotMethodCallCalling public methods with dot notation invokes overloaded dot indexing (R2021b 이후)

함수

모두 확장

listLengthNumber of arguments returned from customized indexing operations (R2021b 이후)
subsrefSubscripted reference
subsasgnRedefine subscripted assignment
subsindex객체를 배열 인덱스로 변환
substructsubsasgn 또는 subsref의 구조체 인수 생성
builtin오버로드된 메서드에서 내장 함수(Built-in Function) 실행
numArgumentsFromSubscriptNumber of arguments for customized indexing based on subsref and subsasgn

도움말 항목