This is my final proect for Numerical Methods that must be done in MATLAB. I wil
ID: 1863146 • Letter: T
Question
This is my final proect for Numerical Methods that must be done in MATLAB. I will add more points if needed. I do not know how to use MATLAB very well. If you can help give me your email i address and i will send you the file that contains the data for the project. Thanks!
Explanation / Answer
Hi, I dont have the data but have written the code for the lagrange interpolation method, which has to be used in the first code.
function yint = Lagrange(x,y,xx)
% Lagrange: Lagrange interpolating polynomial
% yint = Lagrange(x,y,xx): Uses an (n - 1)-order
% Lagrange interpolating polynomial based on n data points
% to determine a value of the dependent variable (yint) at
% a given value of the independent variable, xx.
% input:
% x = independent variable
% y = dependent variable
% xx = value of independent variable at which the
% interpolation is calculated
% output:
% yint = interpolated value of dependent variable
n = length(x);
if length(y)~=n, error('x and y must be same length'); end
s = 0;
for i = 1:n
product = y(i);
for j = 1:n
if i ~= j
product = product*(xx-x(j))/(x(i)-x(j));
end
end
s = s+product;
end
yint = s;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.