23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Function Handles<br />

fhandle(arg1, arg2, ..., argn)<br />

If the function being called takes no input arguments, then use empty<br />

parentheses after the function handle name:<br />

fhandle()<br />

Simple Function Handle Example<br />

The following example calls a function plotFHandle, passing it a handle<br />

for the <strong>MATLAB</strong> sin function. plotFHandle then calls the plot function,<br />

passing it some data and the function handle to sin. Theplotfunctioncalls<br />

thefunctionassociatedwiththehandletocomputeitsy-axisvalues:<br />

function x = plotFHandle(fhandle, data)<br />

plot(data, fhandle(data))<br />

Call plotFhandle with a handle to the sin function and the value shown<br />

below:<br />

plotFHandle(@sin, -pi:0.01:pi)<br />

2-117

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!