function [valor,a,b,c,d] = Spline(vy,vx,xinter)
a=vy;
c=0;b=0;d=0;
h=0;A=eye(length(vx));B=zeros([length(vx)],1);
for i=1:(length(vx)-1)
h(i)=vx(i+1)-vx(i);
end
for i=2:length(h)
A(i,i)=2*(h(i)+h(i-1));
A(i,i-1)=h(i-1);
A(i,i+1)=h(i);
B(i,1)=((3/h(i))*(a(i+1)-a(i)))-((3/h(i-1))*(a(i)-a(i-1)));
end
c=inv(A)*B;
c=c';
for(i=1:length(h))
b(i)=((a(i+1)-a(i))/h(i))-((h(i)/3)*(c(i+1)+2*c(i)));
end
for(i=1:length(h))
d(i)=(c(i+1)-c(i))/(3*h(i));
end
for(i=1:length(d)-1)
if(vx(i)<=xinter&xinter<=vx(i+1))
valor=a(i)+b(i)*(xinter-vx(i))+c(i)*(xinter-vx(i))^2+d(i)*(xinter-vx(i))^3
end
end
disp(valor)
end
EL codigo de spline si hay algun error no dejen de hacermelo saber
ResponderEliminarEste comentario ha sido eliminado por el autor.
ResponderEliminar