Main Content

builtin

Execute built-in function from overloaded method

Description

example

builtin(function,x1,...,xn)executes the built-infunctionwith the input argumentsx1throughxn. Usebuiltinto execute the original built-in from within a method that overloads the function. To work properly, you must never overloadbuiltin.

[y1,...,yn] = builtin(function,x1,...,xn)stores any output fromfunctioniny1throughyn.

Examples

collapse all

Execute the built-in functionality from within an overloaded method.

Create a simple class describing the speed of a particle and providing adispmethod by pasting the following code into a file calledMyParticle.m.

classdefMyParticlepropertiesvelocity;endmethodsfunctionp = MyParticle(x,y,z) p.velocity.x = x; p.velocity.y = y; p.velocity.z = z;endfunctiondisp(p) builtin('disp',p)% call builtinifisscalar(p) disp(' Velocity') disp([' x: ',num2str(p.velocity.x)]) disp([' y: ',num2str(p.velocity.y)]) disp([' z: ',num2str(p.velocity.z)])endendendend

Create an instanceMyParticle.

p = MyParticle(1,2,4)
p = MyParticle Properties: velocity: [1x1 struct] Methods Velocity x: 1 y: 2 z: 4

Input Arguments

collapse all

内置的傅nction name in the MATLAB®path, specified as a character vector or string scalar.functioncannot be a function handle.

Valid input arguments forfunction, specified by supported data types.

More About

collapse all

built-in function

A built-in function is part of the MATLAB executable. MATLAB does not implement these functions in the MATLAB language. Although most built-in functions have a.mfile associated with them, this file only supplies documentation for the function.

You can use the syntaxwhichfunctionto check whether a function is built-in.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

See Also

|

Introduced before R2006a