Undefined function 'eval' for input arguments of type 'double'.

4 visualizaciones (últimos 30 días)
When using the code below:
function [Df]=difc(f,u,h)
syms x
x=u+h; lp=eval(f);
x=u-h; ll=eval(f);
Df=(lp-ll)/(2*h);
end
, the same error keeps appearing ''Undefined function 'eval' for input arguments of type 'double'.''
I would like to know what´s the problem and what can I do to solve it, in order to have a working code.
Thankyou very much
  2 comentarios
Walter Roberson
Walter Roberson el 8 de Nov. de 2012
What are you passing in to the function?
Note: your assignments to "x" are undoing the effect of "syms x".
Ana Luisa
Ana Luisa el 8 de Nov. de 2012
I want to pass the values lp=u+h and ll=u-h, being that u and h are real numbers given by the user

Iniciar sesión para comentar.

Respuesta aceptada

C.J. Harris
C.J. Harris el 8 de Nov. de 2012
You are getting that error because you are trying to evaluate a double. A double is just a double - there is nothing there to evaluate.
What are you expecting the 'eval' function to do?
  2 comentarios
Ana Luisa
Ana Luisa el 8 de Nov. de 2012
I'm trying to calculate the numerical first derivative of a function f using the central differences method with an error of O(h^2).
Walter Roberson
Walter Roberson el 8 de Nov. de 2012
What are you passing in to your routine?

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by