<div dir="ltr">Federico,<div><br></div><div>I am extracting the values of the vectors (vv12 and vt12) from a logic in which it takes data from a spreadsheet that was generated using specific software. The vectors (vv12 and vt12) represent an efficiency curve within the torque x speed plane, I have eleven more of these vectors that vary in size. I believe that I do not have a role in which one depends on the other directly. I tried to follow your first reasoning and arrived at a routine that does not report errors but is not smoothing my curve either, follow the routine:<br></div><div><br></div><div><pre style="font-family:Monospaced"><span style="color:rgb(50,185,185)">clc</span>
<span style="color:rgb(50,185,185)">clear</span>
<span style="color:rgb(0,0,0)">vt12</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(74,85,219)">[</span><span style="color:rgb(188,143,143)">5350.3</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">5380.19</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">5410.08</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">5439.96</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">4149.5</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">4179.35</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">3756.57</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">3602.73</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">3568.12</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">3597.85</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">3681.91</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">3711.59</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">6143.24</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">6172.86</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">6202.49</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">6232.1</span><span style="color:rgb(74,85,219)">]</span>
<span style="color:rgb(0,0,0)">vv12</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(74,85,219)">[</span><span style="color:rgb(188,143,143)">40.16</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">39.93</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">39.71</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">39.49</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">69.04</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">68.54</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">95.32</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">119.26</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">140.49</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">139.32</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">155.62</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">154.37</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">93.27</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">92.82</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">92.38</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">91.94</span><span style="color:rgb(74,85,219)">]</span>

<span style="color:rgb(0,0,0)">c</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(50,185,185)">size</span> <span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">vt12</span><span style="color:rgb(74,85,219)">)</span>
<span style="color:rgb(0,0,0)">a</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(188,143,143)">1</span>
<span style="color:rgb(0,0,0)">b</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(0,0,0)">c</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(188,143,143)">2</span><span style="color:rgb(74,85,219)">)</span>
<span style="color:rgb(0,0,0)">n</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(0,0,0)">c</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(188,143,143)">2</span><span style="color:rgb(74,85,219)">)</span>
<span style="color:rgb(0,0,0)">x</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(50,185,185)">linspace</span> <span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">a</span><span style="color:rgb(0,0,0)">,</span> <span style="color:rgb(0,0,0)">b</span><span style="color:rgb(0,0,0)">,</span> <span style="color:rgb(0,0,0)">n</span><span style="color:rgb(74,85,219)">)</span>

<span style="color:rgb(74,85,219)">[</span><span style="color:rgb(0,0,0)">yvt</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">dvt</span><span style="color:rgb(74,85,219)">]</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(50,185,185)">lsq_splin</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">x</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">vt12</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(50,185,185)">linspace</span> <span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">a</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">b</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">n</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(74,85,219)">)</span>
<span style="color:rgb(74,85,219)">[</span><span style="color:rgb(0,0,0)">yvv</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">dvv</span><span style="color:rgb(74,85,219)">]</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(50,185,185)">lsq_splin</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">x</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">vv12</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(50,185,185)">linspace</span> <span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">a</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">b</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">n</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(74,85,219)">)</span>

<span style="color:rgb(0,0,0)">ys</span><span style="color:rgb(92,92,92)">=</span><span style="color:rgb(50,185,185)">interp</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(50,185,185)">linspace</span> <span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">a</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">b</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">n</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(50,185,185)">linspace</span> <span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">a</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">b</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">n</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">yvt</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">dvt</span><span style="color:rgb(74,85,219)">)</span>
<span style="color:rgb(0,0,0)">xs</span><span style="color:rgb(92,92,92)">=</span><span style="color:rgb(50,185,185)">interp</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(50,185,185)">linspace</span> <span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">a</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">b</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">n</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(50,185,185)">linspace</span> <span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">a</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">b</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">n</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">yvv</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">dvv</span><span style="color:rgb(74,85,219)">)</span>

<span style="color:rgb(174,92,176);text-decoration-line:underline">plot</span> <span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">ys</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">xs</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(188,143,143)">r</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(74,85,219)">)</span>
<span style="color:rgb(174,92,176);text-decoration-line:underline">xlabel</span> <span style="color:rgb(74,85,219)">(</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(188,143,143)">Speed (rpm)</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(74,85,219)">)</span>
<span style="color:rgb(174,92,176);text-decoration-line:underline">ylabel</span> <span style="color:rgb(74,85,219)">(</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(188,143,143)">Torque (Nm)</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(74,85,219)">)</span>
<span style="color:rgb(174,92,176);text-decoration-line:underline">title</span> <span style="color:rgb(74,85,219)">(</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(188,143,143)">Torque x speed values</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(74,85,219)">)</span></pre><pre style="font-family:Monospaced">Any idea how I can proceed with my goal of smoothing the curve to use the color map later?<br></pre><pre style="font-family:Monospaced"><span style="color:rgb(74,85,219)"><br></span></pre><pre style="font-family:Monospaced"><span style="color:rgb(74,85,219)"><br></span></pre></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Apr 11, 2020 at 9:18 PM Federico Miyara <<a href="mailto:fmiyara@fceia.unr.edu.ar">fmiyara@fceia.unr.edu.ar</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF">
    <br>
    Daniel,<br>
    <br>
    I'm afraid I was a bit confused with your application case.<br>
    <br>
    I assumed that there was an independent variable such as time or
    other which the other two, vt12 and vv12, depend on. If this were
    the case, the expected graph could be a curve or rather a trajectory
    with some hysteresis.<br>
    <br>
    But if your data are just measurements in no particular order of
    what is a functional relation of one variable respect to the other,
    for instance vt12 = f(vv12), then the approach is different. You
    should basically sort the independent variable in increasing order
    using gsort and apply the same sorting to the dependent variable:<br>
    <br>
    [x, I] = gsort(vv12,"g","i");<br>
    y = vt12(I);     <br>
    <br>
    Then you can proceed to interpolate with spline or lsg_splin.<br>
    <br>
    Regards,<br>
    <br>
    Federico Miyara<br>
    <br>
    <br>
    <div>On 10/04/2020 21:05, Daniel Stringari
      wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">Federico,<br>
        <br>
        I appreciate the help. Below is a list of the code on which I
        try to plot the data with Isq_splin:<br>
        <br>
        c = size (vt12)<br>
        a = 0<br>
        b = c (1) // c (1) = 16<br>
        n = c (1)<br>
        x = linspace (a, b, n)<br>
        [y, d] = lsq_splin (vt12, vv12, x ')<br>
        plot (y, d, 'r')<br>
        xlabel ('Speed (rpm)')<br>
        ylabel ('Torque (Nm)')<br>
        title ('Torque x speed values')<br>
        <br>
        //vt12 = 5350.3 5380.19 5410.08 5439.96 4149.5 4179.35 3756.57
        3602.73 3568.12 3597.85 3681.91 3711.59 6143.24 6172.86 6202.49
        6232.1<br>
        //vv12 = 40.16   39.93   39.71   39.49   69.04   68.54   95.32  
        119.26   140.49   139.32   155.62   154.37   93.27   92.82  
        92.38   91.94
        <div><br>
          but I'm getting the error: lsq_plin: There are not enough
          points to adjust.<br>
          <br>
          Does anyone understand what could be wrong?<br>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Wed, Apr 8, 2020 at 12:54
          AM Federico Miyara <<a href="mailto:fmiyara@fceia.unr.edu.ar" target="_blank">fmiyara@fceia.unr.edu.ar</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div bgcolor="#FFFFFF"> <br>
            <font face="Courier New">Daniel, <br>
              <br>
              You may try with lsq_spline, which unlike ordinary spline,
              doesn't fit the data exactly, and it doesn't need the data
              with any particular order.<br>
              <br>
              But trying to understand your graph, it seems that you
              should parametrize two variables independently, each one
              with respect to the index. Something like this:<br>
              <br>
              x = [x1, x2, ..., xn]<br>
              y = [y1, y2, ..., yn]<br>
              <br>
              Then you approximate x vs 1:n and y vs 1:n using spline or
              lsq_splin. Finally you plot xs vs ys (the smoothed
              versions of x and y)  <br>
              <br>
              Regards,<br>
              <br>
              Federico Miyara<br>
              <br>
            </font><br>
            <div>On 07/04/2020 22:48, Daniel Stringari wrote:<br>
            </div>
            <blockquote type="cite">
              <pre>Good night friends,
I wrote an email before, but I believe that I was not clear in my words and
so I will write more clearly.

In this annex 1, I have the graph I am generating. Basically I am extracting
values of x (speed) and y (torque) from excel and generating vectors of x []
and y [] to plot internal lines. I want to smooth these lines, but the
functions of the scilab are only for growing points. I thought about
creating cubic splines manually, but I don't know how to do it. Can anybody
help me ?

In addition, I would like to color my chart with level colors according to
the colorbar, but I am not able to implement contour2d for this case.

thanks.

<a href="http://mailinglists.scilab.org/file/t498028/annex_1.png" target="_blank"><http://mailinglists.scilab.org/file/t498028/annex_1.png></a> 



--
Sent from: <a href="http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html" target="_blank">http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html</a>
_______________________________________________
users mailing list
<a href="mailto:users@lists.scilab.org" target="_blank">users@lists.scilab.org</a>
<a href="http://lists.scilab.org/mailman/listinfo/users" target="_blank">http://lists.scilab.org/mailman/listinfo/users</a>

</pre>
            </blockquote>
            <br>
          </div>
          _______________________________________________<br>
          users mailing list<br>
          <a href="mailto:users@lists.scilab.org" target="_blank">users@lists.scilab.org</a><br>
          <a href="http://lists.scilab.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.scilab.org/mailman/listinfo/users</a><br>
        </blockquote>
      </div>
      <br>
      <fieldset></fieldset>
      <pre>_______________________________________________
users mailing list
<a href="mailto:users@lists.scilab.org" target="_blank">users@lists.scilab.org</a>
<a href="http://lists.scilab.org/mailman/listinfo/users" target="_blank">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </div>

_______________________________________________<br>
users mailing list<br>
<a href="mailto:users@lists.scilab.org" target="_blank">users@lists.scilab.org</a><br>
<a href="http://lists.scilab.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.scilab.org/mailman/listinfo/users</a><br>
</blockquote></div>