I need help due to unrecognized function or variable ' x ' error, please.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
0 comentarios
Respuestas (2)
Sulaymon Eshkabilov
el 25 de Nov. de 2023
Here is how to call a function
x = linspace(-10,10);
f=randi(15, size(x));
ANSWER = dd(x,f)
function a = dd(x, f)
n = length(x);
a =f;
for jj=2:n
for ii=n:-1:jj
a(ii) = (a(ii)-a(ii-1))/(x(ii)-x(ii-jj+1));
end
end
end
2 comentarios
Walter Roberson
el 25 de Nov. de 2023
The output shown above, the "ANSWER = " and so on, is output from executing the code here in MATLAB Answers. The code runs successfully, with no error about x
Sulaymon Eshkabilov
el 25 de Nov. de 2023
Put this code in one M-file or MLX editor window, and hit ctrl+enter
x = linspace(-10,10);
f=randi(15, size(x));
ANSWER = dd(x,f)
function a = dd(x, f)
n = length(x);
a =f;
for jj=2:n
for ii=n:-1:jj
a(ii) = (a(ii)-a(ii-1))/(x(ii)-x(ii-jj+1));
end
end
end
0 comentarios
Ver también
Categorías
Más información sobre Variables en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!