POR: QUISPE NELSON FIDEL
function [s]=Spline(x,y,x0)
n=length(x);
for i=1:n-1
h(i)=x(i+1)-x(i);
end
A(1,1)=1;
A(n,n)=1;
for i=2:n-1
A(i,i-1)=h(i-1);
A(i,i)=2*(h(i-1)+h(i));
A(i,i+1)=h(i);
end
B(1)=0;
B(n)=0;
for i=1:n-2
B(i+1)=(3/h(i+1))*(y(i+2)-y(i+1))-(3/h(i))*(y(i+1)-y(i));
end
c=inv(A)*B';
for i=1:n-1
b(i)=(1/h(i))*(y(i+1)-y(i))-(h(i)/3)*(2*c(i)+c(i+1));
d(i)=(c(i+1)-c(i))/(3*h(i));
end
k=1;
for i=1:n-1
if(x0=x(i))
k=i;
end
end
if(x0>=x(n-1))
k=n-1;
end
s=y(k)+b(k)*(x0-x(k))+c(k)*(x0-x(k))^2+d(k)*(x0-x(k))^3;
end
k=i;
end
end
if(x0>=x(n-1))
k=n-1;
end
s=y(k)+b(k)*(x0-x(k))+c(k)*(x0-x(k))^2+d(k)*(x0-x(k))^3;
end
disculpe que tipo de programa es para hacerlo y me darian un ejmplo como funciona
ResponderEliminarEsta en MATLAB y para ejecutarlo debes instalarlo
ResponderEliminar