Function requires more input arguments to run
155 ビュー (過去 30 日間)
My function is:
when I click "Run", the program give me error: "speriamo" requires more input arguments to run. Any other variable I would add is regarded as an unnecessary variable. It's a simple function, what am I doing wrong?
Geoff Hayes 2017 年 3 月 20 日
Cosimo - since this is a function that has one input parameter, then you need to supply that parameter. From the command line you would do
Pressing the RUN button (from the MATLAB file editor) will just call the function as
and not provide any input parameters. Hence the error.
その他の回答 (1 件)
Steven Lord 2017 年 3 月 20 日
When you click Run you call your function with 0 input arguments. The way you have defined the function:
it requires one input argument to run. See this page from the documentation for how to configure the Run button to run your function with an input argument, or call your function at the MATLAB command prompt (the >> or EDU>> prompt in the Command Window) with an input argument.
FYI, this line of code:
doesn't do what you think it does. If you're only going to run this code with a scalar (1-by-1) u then rewrite it as:
if (0 <= u) & (u < pi/3)
If you're going to run this code with a nonscalar u, use logical indexing.