feval - Evaluate function - MATLAB (original) (raw)

Syntax

Description

[[y1,...,yN](#f71-813114-y1yN)] = feval([fun](#f71-813114-fun),[x1,...,xM](#f71-813114-x1xM)) evaluates a function using its name or its handle, and using the input arguments x1,...,xM.

The feval function follows the same scoping and precedence rules as calling a function handle directly. For more information, see Create Function Handle.

example

Examples

collapse all

Evaluate Function with Function Name as Character Vector

Round the value of pi to the nearest integer using the name of the function.

fun = 'round'; x1 = pi; y = feval(fun,x1)

Round the value of pi to two digits to the right of the decimal point.

x2 = 2; y = feval(fun,x1,x2)

Input Arguments

collapse all

fun — Function to evaluate

function name | function handle

Function to evaluate, specified as a function name or a handle to a function. The function accepts M input arguments, and returns N output arguments. To specify fun as a function name, do not include path information.

Invoking feval with a function handle is equivalent to invoking the function handle directly.

Example: fun = 'cos'

Example: fun = @sin

x1,...,xM — Inputs to evaluated function

depends on function

Inputs to the evaluated function. The types of the inputs depend on the function, fun.

Output Arguments

collapse all

y1,...,yN — Outputs from evaluated function

depends on function

Outputs from evaluated function. The types of the outputs depend on the function, fun.

Tips

Extended Capabilities

C/C++ Code Generation

Generate C and C++ code using MATLAB® Coder™.

Usage notes and limitations:

Thread-Based Environment

Run code in the background using MATLAB® backgroundPool or accelerate code with Parallel Computing Toolbox™ ThreadPool.

This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.

Version History

Introduced before R2006a