Minor mistake Writing a function but error

2 visualizaciones (últimos 30 días)
Jhonie Habimana
Jhonie Habimana el 25 de Nov. de 2020
Respondida: ag el 13 de Abr. de 2025
Hello just a quick question, I am writing a code but an error keeps poping up for the function I entered
By any chance would you know why it keeps coming up as a red warning
f=@ (1./x)+(sqrt(x).*exp(x));

Respuestas (1)

ag
ag el 13 de Abr. de 2025
Hi Jhonie,
The issue with the anonymous function you mentioned is that it input argument field. In your case, the input argument "x" needs to be included.
The below code snippet demonstrates the corrected version of your code:
f=@ (x) (1./x)+(sqrt(x).*exp(x));
For more details, please refer to the following MathWorks documentation: Anonymous Functions - https://www.mathworks.com/help/matlab/matlab_prog/anonymous-functions.html
Hope this helps!

Categorías

Más información sobre Interpolation 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!

Translated by