Illustration of a built-in function:
The length function is an illustration of a built-in function which computes a single value; it returns the length of a vector. As an illustration, length (vec) is an expression; it shows the number of elements in the vector vec. This expression can be used in the Command Window or in a script. Usually, the value returned from this expression may be assigned to the variable:
>> vec = 1:3:10;
>> lv = length(vec)
lv =
4
Alternatively, the length of vector could be printed
>> fprintf('The length of the vector is %d\n', length(vec))
The length of the vector is 4