MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
functions is to define a mathematical expression, and then evaluate that expression over a
range of values using a MATLAB® function function, i.e., a function that accepts a
function handle as an input.

For example, this statement creates a function handle named s for an anonymous
function:

s = @(x) sin(1./x);

This function has a single input, x. The @ operator creates the function handle.

You can use the function handle to evaluate the function for particular values, such as

y = s(pi)

y = 0.3130

Or, you can pass the function handle to a function that evaluates over a range of values,
such as fplot:

range = [0.01,0.1];
fplot(s,range)

20 Function Basics

Free download pdf