builtin
从已重载的方法执行内置函数
说明
示例
在类定义中运行重载的函数
从重载的方法内执行内置功能。
创建一个描述粒子速度的简单类,并通过将以下代码粘贴到名为 MyParticle.m
的文件中来提供 disp
方法。
classdef MyParticle properties velocity; end methods function p = MyParticle(x,y,z) p.velocity.x = x; p.velocity.y = y; p.velocity.z = z; end function disp(p) builtin('disp',p) % call builtin if isscalar(p) disp(' Velocity') disp([' x: ',num2str(p.velocity.x)]) disp([' y: ',num2str(p.velocity.y)]) disp([' z: ',num2str(p.velocity.z)]) end end end end
创建实例 MyParticle
。
p = MyParticle(1,2,4)
p = MyParticle Properties: velocity: [1x1 struct] Methods Velocity x: 1 y: 2 z: 4
输入参数
function
— 内置函数名称
字符向量 | 字符串标量
MATLAB® 路径中的内置函数名称,指定为字符向量或字符串标量。function
不能是函数句柄。
x1,...,xn
— function
的有效输入参量
支持的数据类型
function
的有效输入参量,按支持的数据类型指定。
详细信息
内置函数
内置函数包含在 MATLAB 可执行文件中。MATLAB 不会用 MATLAB 语言实现这些函数。虽然大多数内置函数都关联有 .m
文件,但该文件仅提供此函数的文档。
使用语法 which
可以查看函数是否是内置函数。function
扩展功能
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)