MATLAB: Not enough input arguments.

error

It is the first time I try to define a function in Matlab and it doesnt seem to work, The error I am getting is not enough input argument .To make it simple I opened a new function and copied the second example from the documentation for defining functions(<http://www.mathworks.com/help/matlab/ref/function.html)>, clicked F5 and saved under stat. The message on the command window : ">> stat Error using stat (line 2) Not enough input arguments."
function [m,s] = stat(x)
n = length(x);
m = sum(x)/n;
s = sqrt(sum((x-m).^2/n));
end
I use Matlab R2013a

Best Answer

In order to execute the function properly you need to go to the command line and invoke it passing in an argument. For example at the command line type
stat(rand(1,50)*14+8)
Related Question