Main Content

MException.last

가장 최근 uncaught exception 반환

설명

예제

exception = MException.last는 가장 최근에 발생한, 포착되지 않은 MException 객체의 내용을 반환합니다. try/catch 문에서 가장 최근의 예외를 포착한 경우에는 MException.last가 설정되지 않습니다. MException.last는 정적 함수입니다.

예제

MException.last('reset')MException.last에서 반환된 예외의 속성을 지웁니다. 이 옵션은 MExceptionidentifier 속성과 message 속성은 빈 문자형 벡터로 설정하고, stack 속성은 0×1 구조체로 설정하며, cause 속성은 빈 셀형 배열로 설정합니다.

예제

모두 축소

MATLAB®에서 예외를 발생시키고 포착은 하지 않도록 합니다.

A = 25;
A(2)
Index exceeds matrix dimensions.

uncaught exception을 가져옵니다.

exception = MException.last
exception = 

  MException with properties:

    identifier: 'MATLAB:badsubscript'
       message: 'Index exceeds matrix dimensions.'
         cause: {}
         stack: [0x1 struct]

입력 인수 없이 surf 함수를 호출합니다.

surf
Error using surf (line 49)
Not enough input arguments.

uncaught exception을 가져옵니다.

exception = MException.last
exception = 

  MException with properties:

    identifier: 'MATLAB:narginchk:notEnoughInputs'
       message: 'Not enough input arguments.'
         cause: {}
         stack: [1x1 struct]

가장 최근 uncaught exception을 가져옵니다.

MException.last('reset')
exception = MException.last
exception = 

  MException with properties:

    identifier: ''
       message: ''
         cause: {0x1 cell}
         stack: [0x1 struct]

  • MException.last는 명령 창에서만 사용하고 함수 내에서는 사용하지 않습니다.

버전 내역

R2007b에 개발됨

참고 항목

| |