Finding local extrema in Matlab and Octave via fminbnd()

I recently had to work on a Matlab assignment that required the use of fminbnd() to find local extrema. As I typically work on Octave rather than Matlab I ran into some problems getting my code to work within both programmes. As it turned out, Matlab and Octave handle the function slightly differently, so I thought I’d share my findings to save others some headache. First of all, some background information: fminbnd() is a Matlab/Octave function to find a local minimum of a continuous function within a specified interval … [...]