Re: [Scilab-users] Weird error with leastsq()

2020-08-27 Thread Antoine Monmayrant
OK, forget my previous answer. Use this: function [n] = sellmeier(KL, lambda)     K1 = KL(1); K2 = KL(2); K3 = KL(3);     L1 = KL(4); L2 = KL(5); L3 = KL(6);     lambdacarre = lambda.*lambda;     foo1 = lambdacarre - L1;     foo2 = lambdacarre - L2;     foo3 = lambdacarre - L3;     foo =

Re: [Scilab-users] Weird error with leastsq()

2020-08-27 Thread Antoine Monmayrant
Hello, I can tell you what happened: for some values of lambda and some values of K(4,5,6), your function is undefined and the leastsq goes kaboom! It is never a good idea to fit a function that can become undefined for some parameters/xvalues. Try to redefine the function you fit to avoid

[Scilab-users] Weird error with leastsq()

2020-08-27 Thread Dang Ngoc Chan, Christophe
Hello all, Let's talk about optics. I have a glass, its refraction index n varies with the wavelength lamba. I have a CSV file with the corresponding data (verre_HOQ.cvs attached), 52 points. I want to model this with the Sellmeier model https://en.wikipedia.org/wiki/Sellmeier_equation and use