dispstr

버전 1.1.1 (66.3 KB) 작성자: Andrew Janke
A Matlab API for extensible, polymorphic custom object display
다운로드 수: 17
업데이트 날짜: 2022/9/11

Matlab does not provide a general, polymorphic object display function, like Java's toString() method. This makes it hard to write generic code that can do concise debugging display of objects, which is useful for logging, error messages, and interaction at the console.

The Dispstr API provides a concise API for generic, polymorphic, customizable object display, and implementations for the major types that come with Matlab.

Dispstr only provides a few functions and classes:

dispstr() and dispstrs()

prettyprint()

sprintfds(), fprintfds(), errords(), and warningds()

dispstrlib.Displayable and dispstrlib.DisplayableHandle

dispstr() and disptrs() are generic object display functions, which can be overridden by user-defined classes to customize their display. prettyprint() is a function for dumping the details of an array, and respects dispstr/dispstrs. sprintfds() and fprintfds() let you do formatted output that respects dispstr(). errords() and warningds() are variants of error() and warning() that respect dispstr formatting. And @dispstrlib.Displayable is a convenience mixin that makes it easier to write classes that implement dispstr/dispstrs.

When using this library, your user-defined objects can now be displayed inside structs and tables with meaningful data representations, instead of just "<1-by-1 SomeClass>", which Matlab's default disp() does when objects are stuck inside fields of cells or variables of tables.

I think the major value in this library is in establishing the function convention and signatures, not in the implementation code itself.

To use Dispstr, get it on your Matlab path, and then define dispstr() and dispstrs() methods on your classes that you want to have custom displays for. (Or have them inherit from @dispstrlib.Displayable and just define dispstr_scalar().)

This project's home is on GitHub at https://github.com/apjanke/dispstr.

인용 양식

Andrew Janke (2024). dispstr (https://github.com/janklab/dispstr), GitHub. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2016b
R2016b 이상 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Format Reports에 대해 자세히 알아보기
태그 태그 추가

Community Treasure Hunt

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

Start Hunting!

GitHub 디폴트 브랜치를 사용하는 버전은 다운로드할 수 없음

버전 게시됨 릴리스 정보
1.1.1

* Fix a bug with orientation of numeric arrays in dispstr

1.1.0

* Use strings instead of cellstrs
* Add errords() and warningds()
* Fix interpolation of scalar string array arguments in printf functions
* Add printf/error/warning support to Displayable
* Add DisplayableHandle
* Remove dispstrable, superseded by D

1.0.0

이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.
이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.