MATLAB: When calling this function how is the input error caught

input errorMATLAB

This is a test function from the documentation. If I include a letter in the arguments instead of a number matlab reports an error. My question is how does matlab know its an error?
testValues(5,1,2,3,4,5,6,7,8,9,10,a)
function testValues(threshold,varargin)
minInputs = 2;
maxInputs = Inf;
narginchk(minInputs,maxInputs);
for k = 1:(nargin-1)
if (varargin{k} > threshold)
fprintf('Test value %d exceeds %d\n',k,threshold)
end %endif
end %endfor
end %end function
Thanks for any input, haha input get it!
D

Best Answer

since you include a letter a which Matlab think is a variable. so it try to pass the variable a to testValues but that variable doesnot exist so Matlab give you error
either you initialize the variable a
a =1;
testValues(5,1,2,3,4,5,6,7,8,9,10,a)
or you can use string to pass the letter
testValues(5,1,2,3,4,5,6,7,8,9,10,'a')