You can use the fminbnd function in MATLAB to find the local minimum of a function. Here's an example of how to use it on the given function:
main.m224 chars9 lines
This code sets up an anonymous function f that represents the given function, then uses fminbnd to search for the local minimum between 0 and 1. The function returns the location of the minimum (xmin) and the function value at that location (fmin). The code then prints out the result.
Note that this code assumes that the smallest local minimum is somewhere between 0 and 1. If the smallest local minimum is outside this range, you'll need to adjust the inputs to fminbnd accordingly.
gistlibby LogSnag