Why does the function 'details' show more than 'disp' for objects?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Zoltán Csáti
am 17 Feb. 2017
Kommentiert: Zoltán Csáti
am 18 Feb. 2017
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
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 18 Feb. 2017
>> 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 Kommentare
Walter Roberson
am 18 Feb. 2017
Bearbeitet: Walter Roberson
am 18 Feb. 2017
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Whos finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!