MATLAB Answers

cubic spline interpolation based on intermediate iterative points.

조회 수: 4(최근 30일)
eslam abuelnaga
eslam abuelnaga 12 May 2020
x(1)= 1;
y(1)= 5.8;
x(2)= 2.5;
y(2)=12.8125;
x(3)=3;
y(3)=18.2;
x(4)= 4.5;
y(4)= 48.7625;
x(5)= 5.2;
y(5)= 72.496;
So we'e trying to find intermediate points between these points. And will display matrix where we want to display these points plus the new ones we found.
%getting intermediate points
for i=1:n-1
b(i) = (x(i)+x(i+1))./2;
A = x;
C = b(:,[1;1]*(1:size(b,2)));
C(:,1:2:end) = A;
end
C
%code to interpolate the intermediate values
for i=2:n-1
c1= d2(i-1)./(6.*(C(i+1)- C(i-1)));
c2= d2(i+1)./(6.*(C(i+1)- C(i-1)));
c3= (y(i-1)./(C(i+1)-C(i-1)))-((d2(i-1)).*(C(i+1)-(C(i-1)))./6);
c4= ((y(i+1)./(C(i+1)-C(i-1))-(d2(i+1).*(C(i+1)-C(i-1))./6)));
t1= c1.*((C(i+1)-C(i)).^3);
t2= c2.*((C(i)-C(i-1)).^3);
t3= c3.*(C(i+1)-C(i));
t4= c4.*(C(i)-C(i-1));
y(i-1)=t1+t2+t3+t4;
end
C(4)
y(4)
thats what we used but we keep getting the wrong answers, as if we only have the orignal values only
C =
1.0000 1.7500 2.5000 2.7500 3.0000 3.7500 4.5000 4.8500 5.2000 0
ans =
2.7500
ans =
48.7625

  댓글 수: 0

Sign in to comment.

답변(0개)


Translated by