[Scilab-users] fminsearch, error occurs after changing variable name

Adrien Vogt-Schilb vogt at centre-cired.fr
Mon Dec 3 10:19:48 CET 2012


On 02/12/2012 19:06, Jens Simon Strom wrote:
> Thank you Adrien,
> I tried your approach before because it works with optim. It fails. The reason
> is that "x" is a variable of fminsearch which interferes with "my" x.
>
> The consequence is that one has to choose variables that are not defined in
> fminsearch. This is quite disappointing for an elaborated language like Scilab.
>
> Kind regards
> Jens
>    

Hi Jens

I was surprised by your answer, os I tested the code. It works with no 
problem in my Sci 5.4 under winXP:


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

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


popt-popti

  ans  =

     0.    0.


Kind regards









>
>
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20121203/9791df13/attachment.htm>


More information about the users mailing list