Professional Documents
Culture Documents
clc;
clear all;
close all;
n=input('enter the number of points=');
x=input('enter the number of x coordinates=');
y=input('enter the number of y coordinates=');
xg=input('enter the value of xg=');
yg=0;
for i=1:n
L(i)=1;
for j=1:n
if i~=j
L(i)=(L(i)*xg-x(j))/(x(i)-x(j));
end
end
yg=yg+L(i)*y(i);
end
fprintf('the value of xg=%f for yg=%f',xg,yg);
output
solver
yg=interp1(x,y,1.5,'spline')
yg =
-0.9744