Вопрос

I have arbitrary points (8192,4678,1087.2,600,230.4,etc) that I want to interpolate and resample at other define points (100,500.3,802,2045,4399.5125,etc).

I tried cubic spline interpolation but it is using a steady step sampling and depending on the step sampling it may not generate the value I need.

How would you do it ?

Это было полезно?

Решение

If your points are x1=[...] and y1=[...] and you want to evaluate a spline a new base of x2=[...] then you

y2 = spline(x1,y1,x2)

** Example **

x1 = [0,2,4,6,8].'
y1 = [24,25,22,14,6].'

x2 = [2,2.5,3,3.5,4].'
y2 = spline(x1,y1,x2)

    y2 =

       25.0000
       24.7227
       24.1563
       23.2617
       22.0000

plot

Другие советы

It all depends on the underlying physical phenomenon. There is a fine line between interpolating and just making up stuff.

  • I would probably first upsample & filter until I have a meaningful signal at a fixed sampling rate.

  • I would then use some interpolation method to estimate the signal at the goal points.

I would recommend you to consider doing this backwards.

Rather than generating a lot of points and hoping that the points that you need are there, calculate a formula for the interpolation (perhaps piecewise linear or something more complicated) and evaluate the function at the required points.

Assuming you have x = [1 2 3 4 10] and y = [11 22 13 24 11] your linear interpolation at point 6 would be:

24+(6-4) * (11-24) / (10-4) 

It should not be too hard to generalize this.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top