www.gusucode.com > globaloptim 案例源码程序 matlab代码 > globaloptim/ObtainFunctionValueAndMinimizingPointExample.m

    %% Obtain Function Value And Minimizing Point  
% Find a minimum value of a function and report both the location and value
% of the minimum.   

%% 
% Create the following two-variable objective function. On your MATLAB(R)
% path, save the following code to a file named |psobj.m|. 
%
% <include>psobj.m</include>
%
%% 
% Set the objective function to |@psobj|. 
fun = @psobj;  

%% 
% Find the unconstrained minimum of the objective, starting from the point
% |[0,0]|. Return both the location of the minimum, |x|, and the value of
% |fun(x)|. 
x0 = [0,0];
[x,fval] = patternsearch(fun,x0)