Main Content

本页的翻译已过时。点击此处可查看最新英文版本。

自定义类的对象显示

自定义 MATLAB® 如何在命令行窗口中显示类的对象

CustomDisplay 类定义了一个接口,可以用它来自定义 MATLAB 如何显示对象。有关该接口的综述,请参阅Custom Display Interface

函数

display显示有关变量或表达式结果的信息
details显示数组详细信息

matlab.mixin.CustomDisplay用于自定义对象显示的接口
matlab.mixin.util.PropertyGroup用于对象显示的自定义属性列表

主题

自定义显示接口类和方法

Custom Display Interface

The CustomDisplay class provides an API for customizing the display of objects of your class.

How CustomDisplay Works

MATLAB determines the state of an object and then calls specific methods for that state to display the object.

Class with Default Object Display

This example class customizes various aspects of object display.

Role of size Function in Custom Displays

MATLAB uses the size function to help determine the state of the object to display.

用于自定义对象显示的特定方法

Choose a Technique for Display Customization

You can customize object display based on the state of the object and you can change different parts of the display.

Customize Property Display

Change the order and number of properties displayed for an object of your class.

Customize Header, Property List, and Footer

Customize each of the three parts of the display — header, property groups, and footer.

Customize Display of Scalar Objects

Customize the display of scalar objects.

Customize Display of Object Arrays

Customize the display of nonscalar objects, including empty object arrays.

Customize Display for Heterogeneous Arrays

You can call only sealed methods on nonscalar heterogeneous arrays.

Overloading the disp Function

Overloading the disp function provides limited display customization.