It's almost certainly the way you have called the function. You probably didn't pass the same number of input parameters as the function is declared with. The function only discovers that this is a problem when you try to use a parameter that isn't passed.
function [a1, b1, c1] = testfun(a, b, c)
a1 = a;
b1 = b;
c1 = c;
end
To give an example, if you try to run this function from the command-line:
>> testfun(1)
Not enough input arguments.
Error in testfun (line 3)
b1 = b;
>> testfun(1,2)
Not enough input arguments.
Error in testfun (line 4)
c1 = c;
>>
Note that it gives a different error line number based on the number of parameters passed.
Matlab is a funny language - it allows you to define a function with as many parameters as you like, and call it with a different number of parameters (usually less). There's a variable "nargin" which allows the function to make conditional decisions based on missing parameters. A classic use for nargin is to provide default values for extra parameters. e.g.
function [a1, b1, c1] = testfun(a, b, c)
if nargin == 2
c = 0;
end
...
end
1 件のコメント
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/600682-hi-i-m-new-to-matlab-and-i-am-having-some-trouble-could-somebody-please-explain-what-this-error-is#comment_1026562
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/600682-hi-i-m-new-to-matlab-and-i-am-having-some-trouble-could-somebody-please-explain-what-this-error-is#comment_1026562
サインインしてコメントする。