0% found this document useful (0 votes)
17 views

'Interpolación Con El Método de Splines Cúbicos/N/N' '/ndigite El Número de Puntos: '

The document is a MATLAB code for cubic spline interpolation. It takes in a number of data points with x and y coordinates as input, calculates the coefficients a, b, c, and d for the cubic spline interpolation, and displays the coefficients. It uses matrices to solve the system of equations to determine the coefficients by transforming the matrix into an upper triangular matrix and performing back substitution.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

'Interpolación Con El Método de Splines Cúbicos/N/N' '/ndigite El Número de Puntos: '

The document is a MATLAB code for cubic spline interpolation. It takes in a number of data points with x and y coordinates as input, calculates the coefficients a, b, c, and d for the cubic spline interpolation, and displays the coefficients. It uses matrices to solve the system of equations to determine the coefficients by transforming the matrix into an upper triangular matrix and performing back substitution.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

23/12/14 10:13 PM

C:\Users\Mario\Documents\MATLAB\splinecub.m

clc;
clear;
fprintf('Interpolacin con el Mtodo de Splines cbicos\n\n');
n=input('\nDigite el nmero de puntos: ');
for i=1:n
fprintf('x(%d) = ',i);
x(i)=input('\');
fprintf('y(%d) = ',i);
y(i)=input('\');
end
for i=1:n-1
h(i)=x(i+1)-x(i);
end
for i=1:n
a(i)=y(i);
end
v(1)=0;
v(n)=0;
for i=2:n-1
v(i)=3*((a(i+1)-a(i))/h(i))-3*((a(i)-a(i-1))/h(i-1));
end
H(1,1)=1;
H(n,n)=1;
for i=2:n-1
H(i,i)=2*(h(i-1)+h(i));
H(i,i-1)=h(i-1);
H(i,i+1)=h(i);
end
%Resuelve el sistema Hc=v
%Matriz aumentada
for i=1:n
H(i,n+1)=v(i);
end
%Transforma la matriz H en una matriz triangular superior
for k=1:n-1
for i=k+1:n
factor=H(i,k)/H(k,k);
for j=k:n+1
H(i,j)=H(i,j)-factor*H(k,j);
end
end
end
%Sustitucin hacia atras y determina los coeficientes c
c(n)=H(n,n+1)/H(n,n);
for i=n-1:-1:1
sum=H(i,n+1);
for j=i+1:n
sum=sum-H(i,j)*c(j);
end
c(i)=sum/H(i,i);
end
%Determina los coeficientes d y b
for i=1:n-1
d(i)=(c(i+1)-c(i))/(3*h(i));
b(i)=((a(i+1)-a(i))/h(i))-((2*c(i)+c(i+1))*h(i))/3;

1 of 2

23/12/14 10:13 PM

C:\Users\Mario\Documents\MATLAB\splinecub.m

end
%Muestra todos los coeficientes
a
b
c
d

2 of 2

You might also like