Practical 5: Function and Script M-files
Script M-file
Functions on Functions
Suppose a function y = demoFun(x) has been defined in a function M-file demoFun.m
fplot(@demoFun,[a b]) | Plots the function for a ≤ x ≤ b without setting up arrays |
fzero(@demoFun,[a b]) |
Finds one value of x for demoFun(x) = 0 provided that the signs of demoFun(a) and demoFun(b) are opposite. |
fzero(@demoFun,c) | Finds one value of x for demoFun(x) = 0 by starting a search at x = c |
fminbnd(@demoFun,a,b) |
Finds the coordinates of a minimum point of demoFun(x) at the interval |
quadl(@demoFun,a,b) |
Note: quadl uses arrays, so therefore you must set your function up treating x as an array and so using the dot notation for operations. |