MATLAB: Syntax x = fmin(‘fun’,x1,x2)

MATLABoptimization

Syntax
x = fmin('fun',x1,x2)
x = fmin('fun',x1,x2,options)
x = fmin('fun',x1,x2,options,P1,P2, ...)
[x,options] = fmin(...)
are not working by matlab? the message from matlab as follows as:
>> f =@(x) x.^3-2*x-5;
>> x = fmin('f', 0, 2)
Undefined function 'fmin' for input arguments of type 'char'.
Did you mean:
>> x = min('f', 0, 2)
Error using min
MIN with two matrices to compare and a working dimension is not supported.
>> x = fminbnd('f', 0, 2)
Cannot find an exact (case-sensitive) match for 'f'

Best Answer

You’re almost there.
This works:
f =@(x) x.^3-2*x-5;
x = fminbnd(f, 0, 2)
x =
816.4968e-003