If this is the complete code of your function, you are missing the "|function|" declaration. Without it, it is trying to run your code as a script instead of a function. Try starting your code with
Your use of varargin is not as I would expect or recommend. It is used as an input to your function when the number of inputs may not always be the same. It allows you to call a function without having to pass in every input every time. Like the size function you use in your code, I can call it with size(var) of size(var, 1). This is what varargin allows you to do.
Similarly, varargout allows a function to return a variable number of output arguments depending how many outputs are asked for in the calling statement. Using the same function, size, both of these syntaxes are valid.
[m,n] = size(A)
sz = size(A)
Without these, your function would throw an error message when the function were called with anything less than the full complement of input and output arguments.