% optimize 3 link inverse kinematics
% using constraints

global x_d p_d;
global l1 l2 l3
global h_axes link1 link2 link3 target

x_d
p_d
p0

% do optimization
[answer,fval,exitflag]=fminunc(@criterion,p0);

answer
fval
exitflag

% set options for fmincon()
options = optimset('Display','iter','MaxFunEvals',1000000);

% do optimization
[answer,fval,exitflag]=fmincon(@criterion,p0,[],[],[],[],[],[],@constraints,options);

answer
fval
exitflag
