spline interpolation for repeated (non periodic) data?

3 vues (au cours des 30 derniers jours)
Madan Kumar
Madan Kumar le 6 Août 2017
Commenté : Madan Kumar le 6 Août 2017
Hi,
I have a matrix (33175x12) with repeated (non-periodic) values (x below). I tried to interpolate but getting error "The data sites should be distinct.". I think sorting data will not be applicable either because I have sorted year-month-day wise. Program is like,
%a=year,b=month,c=day,x=altitude,y=density
a b c x y
1995 1 1 80 8
1995 1 1 81 9
. . . . .
. . . . .
. . . . .
1995 1 1 90 5
1995 1 2 80 7
1995 1 2 81 6
. . . . .
. . . . .
. . . . .
1995 1 2 100 9
1995 1 2 105 8
1995 1 3 75 9
1995 1 3 76 8
. . . . .
. . . . .
. . . . .
1995 1 3 110 8
. . . . .
. . . . .
. . . . .
I am interpolating data as follows,
xx=80:1:105;
Intdata=spline(y,x,xx); Any help/suggestions. Thank you.

Réponses (1)

John D'Errico
John D'Errico le 6 Août 2017
Um, a spline is a tool that allows you to predict a SINGLE valued function, of the form
y = f(x)
You are calling spline by passing in y in place of x, and x in place of y. So you are creating a relation that is NOT single valued, because thereare multiple values of X at the same locations.
Should spline be smart enough to know that you swapped x and y? How should it be that intelligent? Maybe you WANTED to do that?
Read the help for spline. If you do, it suggests the form:
YY = spline(X,Y,XX);
If you swap the first two arguments, expect problems.
  1 commentaire
Madan Kumar
Madan Kumar le 6 Août 2017
Thank you so much. I also tried it. Problem is that "x" is not monotonic. x repeats but not periodically. Again not all values of x repeat.I am getting error "The data sites should be distinct."

Connectez-vous pour commenter.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by