FOSSEE Optimization Toolbox: Least squares problem call to fmincon does not work (re-try)

Reposted due to problems viewing answers. If you responded previously could you please do so again. Hopefully it should work this time!

I am having problems with the below code. It is a variation of an example listed in the optimization chapter of the Modelling and Simuation in Scilab-Scicos book (pages 109-110 & 114). I can configure the code to work for leastsq and lsqrsolve, but not fmincon from the FOSSEE Optimization toolbox.

All worked examples that call fmincon listed on the FOSSEE site run without problem. These include all 7 examples in 'documentation' plus the spring and circular tank design problems in 'examples'.

The problem has been presented to the Scilab.org comminity and the code syntax checked for potential problems. It complies with the FOSSEE toolbox syntax in both a short and long call with derivative.

How may i configure the least-squares problem to be solved with a call to fmincon?
Any help to resolve the matter would be greatly appreciated.

My system is: Windows 10 Home 64-bit OS, Intel core i5 x64-based processor, Scilab 5.5.2

Regards, Dave

function z=fun(p)
function dz=dfun(p)
function f=costf(p)
f = norm(fun(p))^2;
function g=grad(p)
g = 2*dfun(p)'*fun(p);

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)

Scilab Toolbox Optimization Toolbox 18-01-20, 5:14 p.m. brant

If the book is in public domain, can you give a link to it? It will help in understanding the original problem definition.

28-05-20, 10:30 a.m. rupakrokade

This is my first and favourite online game mahjong let's play hurry up and create the new high score.
24-12-21, 1:45 p.m. berlin0099

Poppy Playtime is set in a toy factory named Playtime. It was a famous factory that produced toys and dolls. One day, all of the staff here mysteriously disappeared. The factory was then abandoned. You play as an ex-worker here and try to solve the mystery after receiving a letter from a staff member who disappeared 10 years ago.
During the game, you will encounter many haunted toys that will hunt you throughout the factory. And it's important to have quick reactions. The mascot of the game is Huggy Wuggy. It's an enormous creature with blue fur and wide red lips.
04-07-22, 2:58 p.m. chunmin89

Log-in to answer to this question.