フィルターのクリア

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 Center および File ExchangeWhos についてさらに検索

タグ

タグが未入力です。

製品

Community Treasure Hunt

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

Start Hunting!

Translated by