0001
0002
0003 rosen = @(x) (1-x(1)).^2 + 105*(x(2)-x(1).^2).^2;
0004
0005
0006
0007 xsol = fminsearchbnd(rosen,[3 3])
0008
0009
0010 xsol = fminsearchbnd(rosen,[3 3],[-1 -1],[4 4])
0011
0012
0013 xsol = fminsearchbnd(rosen,[3 3],[2 2])
0014
0015
0016 xsol = fminsearchbnd(rosen,[-5 -5],[],[0 0])
0017
0018
0019 xsol = fminsearchbnd(rosen,[2.5 2.5],[2 2],[3 3])
0020
0021
0022 xsol = fminsearchbnd(rosen,[0 0],[2 2],[3 3])
0023
0024
0025 xsol = fminsearchbnd(rosen,[0 0],[2 -inf],[inf 3])
0026
0027
0028 opts = optimset('fminsearch');
0029 opts.Display = 'iter';
0030 opts.TolX = 1.e-12;
0031
0032 n = [10,5];
0033 H = randn(n);
0034 H=H'*H;
0035 Quadraticfun = @(x) x*H*x';
0036
0037
0038
0039
0040 LB = [.5 .5 .5 .5 .5];
0041 xsol = fminsearchbnd(Quadraticfun,[1 2 3 4 5],LB,[],opts)
0042
0043
0044 opts = optimset('fminsearch');
0045 opts.TolFun = 1.e-12;
0046
0047 LB = [-inf 2 1 -10];
0048 UB = [ inf inf 1 inf];
0049 xsol = fminsearchbnd(@(x) norm(x),[1 3 1 1],LB,UB,opts)
0050
0051
0052 [xsol,fval,exitflag,output] = fminsearchbnd(@(x) norm(x),[1 3 1 1],LB,UB)
0053