-1

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
Mac.
  • 303
  • 1
  • 12
  • I would try [`fit`](https://www.mathworks.com/help/curvefit/fit.html). It have a good documentation for various of fitting options. – Adiel Mar 20 '17 at 14:10
  • To fit a general type of curve, using [`spline`](https://ch.mathworks.com/help/matlab/ref/spline.html) is a reasonable option. You can then obtain the coefficients of the spline from the command's output. – Richard Mar 20 '17 at 14:34
  • Could you clarify what you mean by "more of the type 'snake' definitively not a type of curve". Maybe give an example of the curve and the kind of equation you are trying to fit to it? – Richard Mar 20 '17 at 14:37
  • Please give us a sample of points and the equation that you _would like_ to get based on them. Also, what are you planning to do with this equation later? For now, I would read about [parametric fitting](https://www.mathworks.com/help/curvefit/parametric-fitting.html). – Dev-iL Mar 20 '17 at 14:44
  • I look for an equation which can represent this points because later I would like use it to do a calculation of distance between this curve and other points placed more or less away from the curve. And Finally keep only points which are closet from the curve – Mac. Mar 20 '17 at 15:01
  • If you plot your points [see image](http://imgur.com/a/2izDV) you will see that the distribution of your points is quite weird for curve fitting. You will need a high degree curve to fit the points and this will lead to overfitting. –  Mar 20 '17 at 15:07

1 Answers1

0

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.

Wolfie
  • 27,562
  • 7
  • 28
  • 55