class
对象的类
说明
示例
输入参数
obj
— 对象或文字
变量或表达式
对象或文字,指定为变量或表达式。
示例: class(date)
输出参量
className
— 类的名称
字符向量
类的名称,以字符向量形式返回。
详细信息
过时的类定义语法
在 MATLAB® 7.6(未通过 classdef
语句定义的类)之前的类定义中,类构造函数调用 class
函数以创建对象。以下 class
函数语法仅在版本 7.6 之前定义的类内应用。
obj = class(s,ClassName)
将 struct
s
用作确定 obj
大小的模式,创建一个由指定类的对象构成的数组。
obj = class(s,ClassName,parent1,parent2,...)
继承指定的父对象的方法和字段。父对象的大小必须与 s
的大小匹配或为标量 (1×1)。如果它们是标量,MATLAB 会执行标量扩展。
obj = class(struct([]),ClassName,parent1,parent2,...)
构造的对象仅包含它从父对象继承的字段。所有父对象必须具有相同的非零大小,以确定返回对象的大小。
objStruct = class(structArray,ClassName,parentArray)
将 parentArray
的每个元素映射到 structArray
中的相应元素,以生成对象的输出数组 objStruct
。
所有数组的大小必须相同。如果 structArray
或 parentArray
的大小为 1×1,则 MATLAB 执行标量扩展以匹配数组大小。
要创建 0×0 大小的对象数组,请将 structArray
和 parentArray
的大小设置为 0×0。
扩展功能
C/C++ 代码生成
使用 MATLAB® Coder™ 生成 C 代码和 C++ 代码。
基于线程的环境
使用 MATLAB® backgroundPool
在后台运行代码或使用 Parallel Computing Toolbox™ ThreadPool
加快代码运行速度。
此函数完全支持基于线程的环境。有关详细信息,请参阅在基于线程的环境中运行 MATLAB 函数。
版本历史记录
在 R2006a 之前推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)