Divided difference in Newton's form error

10 visualizaciones (últimos 30 días)
Daniel
Daniel el 5 de Nov. de 2022
Editada: Torsten el 5 de Nov. de 2022
Above in my function and below is my code to call function in Matlab Grader. The problem I have is that it is telling me the variable a must be a size of [1 6]. It is currently of size [1 5]. Check where the variable is assigned a value. Can anyone tell me how to adjust my a values which is also my coefficients in order to get the size [1 6]?
function a=dd(x,f)
n = 4;
a = [-5, 2, -4, 8, 3];
end
a=dd([0, 1, -1, 2, -2], [-5, -3, -15, 39, -9]);

Respuestas (1)

Torsten
Torsten el 5 de Nov. de 2022
Whatever your code is supposed to do, add a sixth element to the vector "a" in function "dd":
a = [-5, 2, -4, 8, 3, 6];
instead of
a = [-5, 2, -4, 8, 3];
  2 comentarios
Daniel
Daniel el 5 de Nov. de 2022
That would actulally make the variable a have an incorrect value. This what the code is suppose to do:
input: the function f(x) is given by its values stored in the row vector f at points stored in the row vector x. output: the program dd computes the vector of the coefficients a of the interpolating polynomial in the newton form.
Torsten
Torsten el 5 de Nov. de 2022
Editada: Torsten el 5 de Nov. de 2022
output: the program dd computes the vector of the coefficients a of the interpolating polynomial in the newton form.
Ok. Then give it a try.
The lines
n = 4;
a = [-5, 2, -4, 8, 3];
don't do that.

Iniciar sesión para comentar.

Categorías

Más información sobre Polynomials en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by