Documentation

This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English version of the page.

builtin

Execute built-in function from overloaded method

Syntax

``builtin(function,x1,...,xn)``
``[y1,...,yn] = builtin(function,x1,...,xn)``

Description

example

````builtin(function,x1,...,xn)` executes the built-in `function` with the input arguments `x1` through `xn`. Use `builtin` to execute the original built-in from within a method that overloads the function. To work properly, you must never overload `builtin`.```
````[y1,...,yn] = builtin(function,x1,...,xn)` stores any output from `function` in `y1` through `yn`.```

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 a `disp` method by pasting the following code into a file called `MyParticle.m`.

```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 ```

Create an instance `MyParticle`.

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

Input Arguments

collapse all

Built-in function name in the MATLAB® path, specified as a character vector or string scalar. `function` cannot be a function handle.

Valid input arguments for `function`, specified by supported data types.

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 `.m` file associated with them, this file only supplies documentation for the function.

You can use the syntax `which function` to check whether a function is built-in.