Matlab中的类(Class),关于Matlab中class的问题

class

Create object or return class of object

Syntax

str = class(object)

obj = class(s, 'class_name')

obj = class(s, 'class_name', parent1, parent2, ...)

obj = class(struct([]), 'class_name', parent1, parent2, ...)

Description

str = class(object) returns a string specifying the class of object.

The following table lists the object class names that can be returned. All except the last one are MATLAB classes.

logicalLogical array of true and false valuescharCharacter arrayint88-bit signed integer arrayuint88-bit unsigned integer arrayint1616-bit signed integer arrayuint1616-bit unsigned integer arrayint3232-bit signed integer arrayuint3232-bit unsigned integer arrayint6464-bit signed integer arrayuint6464-bit unsigned integer arraysingleSingle-precision floating-point number arraydoubleDouble-precision floating-point number arraycellCell arraystructStructure arrayfunction handleArray of values for calling functions indirectly'class_name'Custom MATLAB object class or Java class

obj = class(s, 'class_name') creates an object of MATLAB class 'class_name' using structure s as a template. This syntax is valid only in a function named class_name.m in a directory named @class_name (where 'class_name' is the same as the string passed in to class).

obj = class(s, 'class_name', parent1, parent2, ...) creates an object of MATLAB class 'class_name' that inherits the methods and fields of the parent objects parent1, parent2, and so on. Structure s is used as a template for the object.

obj = class(struct([]), 'class_name', parent1, parent2, ...) creates an object of MATLAB class 'class_name' that inherits the methods and fields of the parent objects parent1, parent2, and so on. Specifying the empty structure struct([]) as the first argument ensures that the object created contains no fields other than those that are inherited from the parent objects.

Examples

To return in nameStr the name of the class of Java object j,

nameStr = class(j)

To create a user-defined MATLAB object of class polynom,

p = class(p, 'polynom')

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值