spline interpolation for repeated (non periodic) data?
조회 수: 3 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (1개)
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.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!