Write a function that produces a plot.

Write a function that takes arrays x and y as inputs and produces a plot of the Lagrange interpolating polynomial. The plot should also include markers for the data points in x and y. This function will need to ll in a divided di[ff]erences table and will need to evaluate the interpolating polynomial at enough points to produce a smooth plot. There is an outline for the code on Blackboard if you need help. You may want to test your algorithm on a table you have lled in by hand. Email this function le to your grader.
As an example, for the following data,
x=[0 3 4.5 6 9];
y=[0 .5 .7071 .8660 1];
This is what I have so far
x = [1 1.2 1.5 1.7 2.0];
y = [1 0.6944 0.4444 0.3460 0.2500];
n = length(x);
n2 = length(y);
F = ones(n2,n+1);
for i = 2:n
for j = 2:i
F(:,j) = F(:,j).*(x'-x(i))/(x(j)-x(i));
end
end
disp(F)

3 comentarios

Steven Lord
Steven Lord el 9 de Mzo. de 2017
If you post what you've done to try to solve this problem and ask a specific question you may receive some suggestions about how to move forward.
randal urso
randal urso el 9 de Mzo. de 2017
I have posted what i have so far.

Respuestas (0)

La pregunta está cerrada.

Preguntada:

el 9 de Mzo. de 2017

Cerrada:

el 20 de Ag. de 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by