Interpolation_Spline0. M:
The function yy=Interpolation_Spline0 (x, y, xx)
N=length (x);
A=y (1: end - 1);
B=zeros (n - 1, 1);
D=zeros (n - 1, 1);
Dx=diff (x);
Dy=diff (y);
A=zeros (n);
B=zeros (n, 1);
A (1, 1)=1;
A (n, n)=1;
For I=2: n - 1
A (I, I - 1)=dx (I - 1);
A (I, I)=2 * (dx (I - 1) + dx (I));
A (I, I + 1)=dx (I);
B (I)=3 * (dy (I)/dx (I) - dy (I - 1)/dx (I - 1));
End
C=A \ B;
For I=1: n - 1
D (I)=(c (I + 1) - c (I))/(3 * dx (I));
B (I)=dy (I)/dx (I) - dx (I) * (2 * c (I) + c (I + 1))/3;
End
[mm, nn]=size (xx).
Yy=zeros (mm, nn);
For I=1: mm * nn
For 2=1: n - 1
If xx (I) & gt;=x (ii) & amp; & Xx (I) & lt; X (2 + 1)
J=2;
break;
Else if xx (I)==x (n)
J=n - 1;
End
End
Yy (I)=a (j) + b (j) * (xx (I) - (j)) x + c (j) * (xx (I) - (j)) x ^ 2 + d (j) * (xx (I) - (j)) x ^ 3;
End
Yt1. M:
The function y=yt1 (x0, y0, f_0 f_n, x)
N=length (x0);
Z=length (y0);
H=zeros (n - 1, 1);
K=zeros (n - 2, 1);
L=zeros (n - 2, 1);
S=2 * eye (n);
For I=1: n - 1
H (I)=x0 (I + 1) - x0 (I);
End
For I=1: n - 2
K (I)=h (I + 1)/(h (I + 1) + h (I));
L (I)=1 - k (I);
End
K=[1 k];
L=1] [l;;
For I=1: n - 1
S (I, I + 1)=k (I);
S (I + 1, I)=l (I);
End
F=zeros (n - 1, 2);
For I=1: n - 1
F (I, 1)=(y0 (I + 1) - y0 (I))/(x0 (I + 1) - x0 (I));
End
D=zeros (n - 2, 1);
For I=1: n - 2
(I, 2)=F (F (I + 1, 1) - F (I, 1))/(x0 (I + 2) - x0 (I));
D (I, 1)=6 * F (I, 2);
End
D0=6 * (F (1, 2) - f_0)/h (1);
Dn=6 * (f_n - F (n - 1, 2))/h (n - 1);
D=(d0, D, dn),
M=S \ D;
For I=1: length (x)
For j=1: n - 1
If (x (I) & lt;=x0 (j + 1)) & amp; (x (I) & gt;=x0 (j))
Y (I)=(m (j) * (x0 (j + 1) - x (I)) ^ 3)/(6 * h (j)) +...
(m (j + 1) * (x (I) - x0 (j)) ^ 3)/(6 * h (j)) +...
(y0 (j) - (m (j) * h (j) ^ 2)/6) * (x0 (j + 1) - x (I))/h (j) +...
(y0 (j + 1) - (m (j + 1) * h (j) ^ 2)/6) * (x (I) - x0 (j))/h (j);
break;
The else continue;
End
End
End
X=[]; % for years
> Y=[]; % cultural value
> Xx=[]; Year % want
> Yy=Interpolation_Spline0 (x, y, xx)