Not enough input arguments error

I'm new to Matlab and following a beginner textbook, and I get the following error message for this simple code:
Not enough input arguments.
Error in price (line 3)
= items*130
function price(items)
% If Construct example
price = items*130
if items > 5
price = items*160
end
Thanks in advance

답변 (1개)

Star Strider
Star Strider 2018년 11월 4일

0 개 추천

Most likely that is due to your using the green Run option in the Editor rather than calling your function from a script, as it was designed for (in this instance).
If a function has arguments (not all do), you need to provide those arguments. This is most easily (and reliably) done by calling it from a script.

카테고리

도움말 센터File Exchange에서 Scope Variables and Generate Names에 대해 자세히 알아보기

질문:

LR
2018년 11월 4일

답변:

2018년 11월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by