how do I evaluate the value of an expression?
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Matteo Masto
el 2 de Nov. de 2019
Respondida: Joshua Hodson
el 10 de Feb. de 2021
x = [-2:0.01:1];
f = (x.^2) -x +1 - (exp(-x));
x1 = -1.9;
f(x1)
this gives me the error:
Array indices must be positive integers or logical values
How can I manage to extract the right value of f at x1?
thanks!
0 comentarios
Respuesta aceptada
Star Strider
el 2 de Nov. de 2019
Try this:
f = @(x) (x.^2) -x +1 - (exp(-x));
x1 = -1.9;
fx1 = f(x1)
creating an anonymous function and producing:
fx1 =
-0.175894442279269
2 comentarios
Más respuestas (1)
Ver también
Categorías
Más información sobre Numeric Types 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!