AME 150L Lecture Notes - Lecture 19: Numerical Integration, Eval
Document Summary
Ame 150: introduction to computational methods - lecture #19: function functions function functions: functions that use names of other functions in the input argument list. Ex: predefined matlab function fzero fzero(fun, [xmin xmax]) Fun(x) fun(xmin) } fun(xmax) } must differ in sign (one positive and one negative) only one zero return is error fun(x)=0 x=x0 fun character string denoting the function. @cos = cos": matlab predefined function: quad(fun,xmin,xmax) = numerical quadrature(integral) xmax xmin. Design of function functions relies on eval and feval. Eval(string) - evaluates a character string as if it were typed in the command window. X = string sin(pi/2) would appear in the command window. Y = eval(string) = 1 will look at this string and produce the same result as if sin(pi/2) had been typed in the command window. Feval(fun,value) - takes a function defined by m-file fun. m and evaluates it at specified input value.