f = @(x) -exp(-x.^2).*cos(7.*x-1).^2; x = linspace(-3,3,1000); plot(x,f(x)) x1 = fminunc(f,0.16) x2 = fminunc(f,-0.33)