NMSMAX Nelder-Mead simplex method for direct search optimization. [x, fmax, nf] = NMSMAX(FUN, x0, STOPIT, SAVIT) attempts to maximize the function FUN, using the starting vector x0. The Nelder-Mead direct search method is used. Output arguments: x = vector yielding largest function value found, fmax = function value at x, nf = number of function evaluations. The iteration is terminated when either - the relative size of the simplex is <= STOPIT(1) (default 1e-3), - STOPIT(2) function evaluations have been performed (default inf, i.e., no limit), or - a function value equals or exceeds STOPIT(3) (default inf, i.e., no test on function values). The form of the initial simplex is determined by STOPIT(4): STOPIT(4) = 0: regular simplex (sides of equal length, the default) STOPIT(4) = 1: right-angled simplex. Progress of the iteration is not shown if STOPIT(5) = 0 (default 1). STOPIT(6) indicates the direction (ie. minimization or maximization.) Default is 1, maximization. set STOPIT(6)=-1 for minimization If a non-empty fourth parameter string SAVIT is present, then `SAVE SAVIT x fmax nf' is executed after each inner iteration. NB: x0 can be a matrix. In the output argument, in SAVIT saves, and in function calls, x has the same shape as x0. NMSMAX(fun, x0, STOPIT, SAVIT, P1, P2,...) allows additional arguments to be passed to fun, via feval(fun,x,P1,P2,...).