spline interpolation for repeated (non periodic) data?

조회 수: 3 (최근 30일)
Madan Kumar
Madan Kumar 2017년 8월 6일
댓글: Madan Kumar 2017년 8월 6일
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.

답변 (1개)

John D'Errico
John D'Errico 2017년 8월 6일
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
Madan Kumar
Madan Kumar 2017년 8월 6일
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."

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by