Skip to content

exp 6 #5

Description

@legend17-dot

clc;clear; format long;
x=[0,1,2];y=[1,2,9];xp=1.5;
n=length(x);yp=0;
for i=1:n
L=1;
for j=1:n
if j~=i
L=L*(xp-x(j))/(x(i)-x(j));
end
end
yp=yp+y(i)*L;
end

fprintf('y at x=1.5=%.8f\n',yp);

clc;
clear;
format long;

x = [0, 0.5, 1];y = [0, 0.4794, 0.8415];xp = 0.8;

n = length(x);yp = 0;

for i = 1:n
L = 1;

for j = 1:n
    if j ~= i
        L = L * (xp - x(j)) / (x(i) - x(j));
    end
end

yp = yp + y(i) * L;

end

fprintf('y(0.8) = %.8f\n', yp);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions