Search code examples
matlabcurve

Equation of curve


Is it possible to obtain the equation of a curve knowing that we have all the coordinates X and Y of each points making up this curve? I think that it is possible, but how ? (knowing that it is not a conventional curve of type: right, parabola, hyperbola ... more of the type "snake" definitively not a type of curve)

Sample of points : first column is X and second Y

795 365
816 365
24  365
25  365
222 366
312 366
313 366
317 366
318 367
343 367
344 367
669 367
751 368
752 368
763 368
795 368
796 368
814 369
815 369
23  369
313 369
314 369
315 370
316 371
344 372
345 372

Solution

  • You might not need a curve, a solution using interp1 to interpolate between your data points could be best. Especially as you say your use case is to see how far other points are from this data set.

    For instance, say you have two column vectors (x and y) of data. You can define some anonymous function f

    f = @(xin) interp1(x,y,xin);
    

    There are different interpolation (and extrapolation) options for interp1, see the documentation. The default is simply linear interpolation, but you can use splines etc...

    Then you can use this by supplying an x value (say 4.2 for this example) within the original range of data for interpolation...

    y_interpolated = f(4.2);
    

    Basically using it as a lookup table.