can someone give me a simple example in how to use this code to plot a Lagrange
ID: 3605926 • Letter: C
Question
can someone give me a simple example in how to use this code to plot a Lagrange polynomial?
thank you!
Explanation / Answer
function y=mylagrange (x,pointx,pointy)
ndp=x;
y=1
for k=1:ndp
if k~=pointx
y=y*(x-x(pointx))/pointy-x
(x-x(pn))/(x(p1)-x(p2));
end
--------------------------
if true
x=[1 3 4 5 8]
n=length(x)
for j=1:n
for x=x(1:n)
mylagrange(x,pointx,pointy)
plot(x,sum(mylagrange(x,pointx,pointy)
hold on
end
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.