To find the local minimum of a function in MATLAB, we can use the fminsearch
function. Since we are working with a 1D function, we just need to provide an initial guess for the minimum location.
Here's an example code to find the smallest local minimum of the given function:
main.m446 chars19 lines
Note that we use fminbnd
to check if the found minimum is indeed a local minimum within a small interval around it. The tolerance of 1e-6
is chosen arbirarily, you might want to adjust it to your needs.
gistlibby LogSnag