Many thanks for getting back Stéphane. I tried your suggestion with the gradient option, but got a problem:
!--error 26 Too complex recursion! (recursion tables are full) at line 2 of function fun called by : at line 2 of function fGrad called by : sample_fGrad=fGrad(x0) at line 649 of exec file called by : init=fun(x0) The minimalist call also returned a problem: y=numderivative(fun,x) !--error 4 Undefined variable: 10000000000000G*1000100 at line 29 of function flag1 called by : at line 16 of function fGrad1 called by : init=fun(x0) at line 842 of exec file called by : API Error: in error: bad call to getVarAddressFromPosition! (1rst argument). Probably a stupid error on my part, but cannot spot it! Code: function z=fun(p) z=DAT(:,2)-p(1)*exp(p(2)*DAT(:,1))-p(3)*ones(DAT(:,1)) endfunction //function dz=dfun(p) // var=exp(p(2)*DAT(:,1)) // dz=[-var.. // -p(1)*DAT(:,1).*var.. // -ones(var)] //endfunction function f=costf(p) f = norm(fun(p))^2; endfunction //function g=grad(p) // g = 2*dfun(p)'*fun(p); //endfunction DAT=[0 0;0 1;1 1;2 1.5;2 2]; p0=[0 0 0]; xopt = fmincon(costf,p0,[],[]) //options = list("GradObj",grad) //xopt = fmincon(costf,p0,[],[],[],[],[],[],[],options) fmincon.sce <http://mailinglists.scilab.org/file/t490392/fmincon.sce> -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html _______________________________________________ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users