How to create function

3 visualizaciones (últimos 30 días)
Deeksha kaila
Deeksha kaila el 2 de Oct. de 2017
Respondida: Steven Lord el 2 de Oct. de 2017
I typed a function Function y=lf(x) y=log(1-exp(-1/x)) Bt display an error message 'not enough input arguments'

Respuestas (2)

Star Strider
Star Strider el 2 de Oct. de 2017
MATLAB is case-sensitive. Use function, not Function.
This works:
function y=lf(x)
y = log(1-exp(-1./x));
end
The end call is not absolutely required. However, it creates neater, unambiguous code, so I always use it.

Steven Lord
Steven Lord el 2 de Oct. de 2017
Because this function requires one input, you cannot run it simply by pressing the green triangle in the Editor. Either call it with an input argument in the Command Window or press the small downward-facing black triangle below the green triangle and enter the code (with the input argument) to run the function in the "type code to run" box as shown in this documentation example.

Categorías

Más información sobre File Operations 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