Explanation:
A function you are trying to call expects fewer input/output arguments, or more input/output arguments, than you have provided it
Common causes:
1) You have passed a function more input arguments than it expected to receive, perhaps by passing a list of inputs rather than a vector of inputs, or have tried to obtain two outputs from a function that only returns one.
2) You have multiple functions with the same name. One possible way when this can happen is when you create a function with the same name as an in-built MATLAB function. To identify which function is being called by MATLAB, use the WHICH command as follows:
which -all <function-name>
Solution:
Stop MATLAB on the line where the error occurs. Verify that you have specified the correct number of input and/or output arguments, using WHICH to determine which version of the function you are using if necessary. If this occurs immediately when you try to run your main function, verify that it can accept and/or return sufficient arguments. Another way to debug this problem is to use the NARGIN and NARGOUT functions. When you call NARGIN or NARGOUT inside a function, it returns how many inputs or outputs are actually specified in the call to the function.
Finally, using the DBTYPE function in the following syntax
will display the first line of the MATLAB function file, which can be useful for viewing the input and output arguments that the function expects.
Example demonstrating this error:
TooManyArguments.m
Best Answer