Variable number of output arguments:
The variable number of output arguments can also be identified. For illustration, the one input argument is passed to the below function typesize. The function always return a character identifying whether the input argument was a vector ('v'), scalar ('s'), or matrix ('m'). This is returned through the output argument arrtype. In addition, when the input argument was a vector the function returns the length of the vector, and when the input argument was a matrix the function returns the number of rows & columns of the matrix. The output argument varargout is used; and it is a cell array. Therefore, for a vector of length is returned through the varargout and for a matrix both the number of rows & columns are returned through the varargout.
>> typesize(5)
ans =
s
>> [arrtype, len] = typesize(4:6)
arrtype =
v
len =
3
>> [arrtype, r, c] = typesize([4:6;3:5])
m
r =
2
c =