Matlab function to get text for display of object property
이전 댓글 표시
I would like to change the way that the Matlab display function works on my object. I would like to reorganize the properties (which I know I could do if I redefined them in a different order), but additionally add a few more properties and descriptive lines. I would like to keep the functionality that Matlab offers by converting of all my properties to strings, truncating where necessary or simply summarizing by class and size in other cases. Does this functionality exist?
Here's an example:
auth_header: [1x1 struct]
signature_method: 'HMAC-SHA1'
The structure is conveniently display as [1x1 struct].
Thus a function like the following would be great:
text = getPropText(obj,'auth_header');
text => '[1x1 struct]'
I could reproduce this functionality but it would be nice if I could just get access to the underlying function. Thoughts?
채택된 답변
추가 답변 (1개)
Ken Atwell
2012년 4월 1일
0 개 추천
You can overload the display and/or disp methods for your object, which I believe will allow you to do what you want. See Displaying Objects in the Command Window within the object-oriented programming section of the MATLAB documentation.
댓글 수: 2
Jim Hokanson
2012년 4월 2일
Ken Atwell
2012년 4월 3일
Gotcha, but I don't have a clear recommendation here. I don't know a direct why to capture the result of a disp instead of echoing to the Command Window.
You may be able to use the <http://www.mathworks.com/help/techdoc/ref/diary.html diary> command to capture the output to a file, and then parse that file.
카테고리
도움말 센터 및 File Exchange에서 Whos에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!