How to create function
조회 수: 3 (최근 30일)
이전 댓글 표시
I typed a function Function y=lf(x) y=log(1-exp(-1/x)) Bt display an error message 'not enough input arguments'
댓글 수: 0
답변 (2개)
Star Strider
2017년 10월 2일
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.
댓글 수: 0
Steven Lord
2017년 10월 2일
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 File Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!