필터 지우기
필터 지우기

Why does the function 'details' show more than 'disp' for objects?

조회 수: 1 (최근 30일)
Zoltán Csáti
Zoltán Csáti 2017년 2월 17일
댓글: Zoltán Csáti 2017년 2월 18일
According to the documentation, the 'details' function provides more information when the input is an object than 'disp'. However, looking at the code of 'details' (which is not a built-in function), it just invokes 'disp'. Then how can it result in a different output? Used MATLAB version: R2015b, Linux 64 bit

채택된 답변

Walter Roberson
Walter Roberson 2017년 2월 18일
>> which -all details
/Applications/MATLAB_R2017a.app/toolbox/matlab/lang/details.m
details is a built-in method % string method
details is a built-in method % meta.PackageList method
details is a built-in method % handle method
details is a built-in method % meta.ClassList method
details is a built-in method % meta.FunctionList method
details is a built-in method % meta.TypeList method
details is a built-in method % matlab.mixin.internal.indexing.Paren method
[...]
So the disp() source you are looking at is only used for objects that do not have a more specific method.
  댓글 수: 3
Walter Roberson
Walter Roberson 2017년 2월 18일
편집: Walter Roberson 2017년 2월 18일
So the details() source you are looking at is only used for objects that do not have a more specific method.
That is, there is not just one details.m that is called for everything. When MATLAB encounters a call to details(), it first checks to see if the parameter is an object (in the Object Oriented Programming sense). If it is an object, then it checks to see if there is a details method defined for that object; if it is then it calls that details method, rather than calling the details.m that you found.
Example:
>> p = plot(rand(1,5)); which details(p)
details is a built-in method % matlab.graphics.chart.primitive.Line method
Notice that I passed p in to which, so that it can look up to find out which details() method to call for an object with the same data type as p has.
Zoltán Csáti
Zoltán Csáti 2017년 2월 18일
Now it is clear. Thank you for explaining.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by