<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
      charset=windows-1252">
  </head>
  <body>
    <p>OK, forget my previous answer.</p>
    <p>Use this:</p>
    <p>function [n] = sellmeier(KL, lambda)<br>
          K1 = KL(1); K2 = KL(2); K3 = KL(3);<br>
          L1 = KL(4); L2 = KL(5); L3 = KL(6);<br>
          lambdacarre = lambda.*lambda;<br>
          foo1 = lambdacarre - L1;<br>
          foo2 = lambdacarre - L2;<br>
          foo3 = lambdacarre - L3;<br>
          foo = 1./(foo1.*foo2.*foo3);<br>
          n = sqrt(1 +...<br>
          lambdacarre.*(K1*foo.*foo2.*foo3 + K2*foo.*foo1.*foo3 +
      K3*foo.*foo1.*foo2));<br>
          n=real(n);<br>
      endfunction</p>
    <p>Now it works.</p>
    <p>Antoine</p>
    <p>PS: Here is the issue: your sellmeier function should be
      bulletproof and gracefully return real values no matter what
      parameters you feed to it.<br>
    </p>
    <div class="moz-cite-prefix">Le 27/08/2020 à 16:52, Dang Ngoc Chan,
      Christophe a écrit :<br>
    </div>
    <blockquote type="cite"
cite="mid:AM0PR07MB393746021EE81DE351843C74E5550@AM0PR07MB3937.eurprd07.prod.outlook.com">
      <pre class="moz-quote-pre" wrap="">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
<a class="moz-txt-link-freetext" href="https://en.wikipedia.org/wiki/Sellmeier_equation">https://en.wikipedia.org/wiki/Sellmeier_equation</a>
and use for this the attached script (regression_sellmeier.sce).

Mind to set the path at line 7 of the script if you want to run it.

My problem:
I can run piecewise regression,
i.e. it runs when I work with the points 1 to 25, 13 to 39, or 32 to 52;
e.g. at lines 11 and 12, it works when I use

// ----------

lambda = 1e-3*donnees(1:25, 1); // en µm

nexp = donnees(1:25, 2);

// ----------

but when I try to extend these ranges (and of course when I try to use all the points),
it fails with the following error:

5215700pt: Wrong type for output argument #1: Real scalar expected.

Can anyone tell me what goes on here?

Regards

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer


General
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
    </blockquote>
  </body>
</html>