Sunteți pe pagina 1din 2

Interpolacin de Lagrange en Matlab

Este es el programa que interpola


function y0 = lagrange_interp(x, y, x0)
% x is the vector of abscissas.
% y is the matching vector of ordinates.
% x0 represents the target to be interpolated
% y0 represents the solution from the Lagrange interpolation
y0 = 0;
n = length(x);
for j = 1 : n
t = 1;
for i = 1 : n
if i~=j
t = t * (x0-x(i))/(x(j)-x(i));
end
end
y0 = y0 + t*y(j);
end

Para Calcular el Bo
>> y = [1.973, 1.796, 1.707, 1.58,1.469, 1.374, 1.277, 1.223];

x= [4537.7, 3926.7, 3570.5, 2859.4, 2148.2, 1437, 725.9, 370.3];

x0=3675;

y0=lagrange_interp(x,y,x0)

y0 =

1.7306

Para la viscosidad (mu)


>> y = [0.301, 0.305, 0.325, 0.4, 0.532, 0.711, 0.972, 1.195];
x= [4537.7, 3926.7, 3570.5, 2859.4, 2148.2, 1437, 725.9, 370.3];
x0=3675;
y0=lagrange_interp(x,y,x0)

y0 =
0.3181

S-ar putea să vă placă și