Presentation is loading. Please wait.

Presentation is loading. Please wait.

Function Handles UC Berkeley Fall 2004, E Copyright 2005, Andy Packard

Similar presentations


Presentation on theme: "Function Handles UC Berkeley Fall 2004, E Copyright 2005, Andy Packard"— Presentation transcript:

1 Function Handles UC Berkeley Fall 2004, E Copyright 2005, Andy Packard. This work is licensed under the Creative Commons Attribution-ShareAlike License. To view a copy of this license, visit or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

2 Function handles and feval
Several Matlab functions solve your problem by repeatedly calling functions that you supply finding zeros of a function (fzero) Integrating a function (trapz, quad) Integrating a differential equation (ode45) minimizing a function (fminbnd, fminsearch) For example, in calling fzero, you must pass a reference-to-the-function (called a function handle) that you want fzero to find the zeros of. Use operator to get the reference. >> shan >> class(shan) >> feval(shan,linspace(0,pi,5)) New data type: add to list with double, cell, char, struct. Any function (built-in, mfile, etc)

3 Function handles and feval
General syntax for feval is [out1,out2,…] = feval(FuncH,arg1,arg2,…) function handle Output argument list Input argument list


Download ppt "Function Handles UC Berkeley Fall 2004, E Copyright 2005, Andy Packard"

Similar presentations


Ads by Google