Search code examples
scilab

Noisy data presented in tabular form are given. Fit and build a model curve


Noisy data presented in tabular form are given. Fit and build a model curve. Choose a functional dependence of the form:

enter image description here


Solution

  • Here is the Scilab code for your first example, you will be able to adapt it to other cases. To evaluate the obtained polynomial F use Scilab function horner (see the associated help page by typing help horner).

    gd = [1.2 1.4 1.6 1.8 2.1 2.2 2.4 2.6 2.8 3.1]';
    Fd = [1.55 2.73 3.91 5.51 7.11 9.12 11.12 12.91 15.45 17.91]';
    c = [ones(gd), gd, gd.^2, gd.^3]\Fd;
    F = poly(c,"g","coeff");
    disp(F)
    

    the above script displays

      7.6508968 -14.91761g +9.8440484g² -1.2735795g³
    

    You can plot the graph of the polynomial and the original noisy data like this:

    g = linspace(1.2,3.1,100);
    plot(g, horner(F,g),gd,Fd,'o')
    

    enter image description here