主要内容

定义系统对象信息

这个示例展示了如何定义要为System对象™显示的信息。

定义系统对象信息

你可以自己定义信息方法显示System对象的特定信息。默认的infoImpl方法返回一个空结构。这infoImpl方法返回详细信息信息被称为使用信息(x,“细节”)或者只在调用时计数信息信息(x)

方法(Access = protected)函数s = infoImpl (obj,变长度输入宗量)如果输入参数个数> 1 & & strcmp (“细节”,varargin(1) s = struct(“名字”“计数器”“属性”结构(“CurrentCount”obj。数,...“阈值”obj.Threshold));其他的s =结构(“数”, obj.Count);结束结束结束

用完成类定义文件InfoImpl

classdef计数器< matlab。系统% Counter超过阈值的计数属性阈值= 1结束属性(DiscreteState)数结束方法(访问=保护)函数setupImpl (obj) obj。数= 0;结束函数resetImpl (obj) obj。数= 0;结束函数y = stepImpl (obj, u)如果obj. threshold (u > obj. threshold)数= obj。数+ 1;结束y = obj.Count;结束函数s = infoImpl (obj,变长度输入宗量)如果输入参数个数> 1 & & strcmp (“细节”,varargin(1) s = struct(“名字”“计数器”...“属性”结构(“CurrentCount”...obj。数,“阈值”obj.Threshold));其他的s =结构(“数”, obj.Count);结束结束结束结束

另请参阅