On 02/12/2012 09:33, Jens Simon Strom wrote:
Hello Scilab experts,

This script functions:

function SAQ=!f(p), SAQ=sum( ( p(1)+p(2)*xi-yi ).^2 ), endfunction
xi=1:1000 ;
yi=2*xi+3;
popt=fminsearch(!f,[0;0])

If I replace yi by y everywhere the script functions too as expected.

If I replace xi by x everywhere an error occurs: "Inconsistent subtraction in
function !f.

What is wrong here?

Kind regards
Jens


_______________________________________________
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users
hi

that's because the way scilab uses local variables

try "declaring" all the variables needed in your function:

function SAQ=!f(p,x,y), SAQ=sum( ( p(1)+p(2)*x-y ).^2 ), endfunction

then use the "list approach" in fminsearch

x=1:1000 ;
y=2*xi+3;
popt=fminsearch(list(!f,x,y),[0;0]))


I did not try this code because it's sunday and i don't want to.
but tell me if it does not work.


kind regards

AVS
_______________________________________________
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users

Reply via email to