LENGTH Function

LENGTH (matrix) ;

The LENGTH function takes a character matrix as an argument and produces a numeric matrix as a result. The result matrix has the same dimensions as the argument and contains the lengths of the corresponding string elements in matrix. The length of a string is equal to the position of the rightmost nonblank character in the string. If a string is entirely blank, its length value is set to 1. An example of the LENGTH function follows:

c = {"Hello" "My name is Jenny"};
b = length(c);
print b;

Figure 23.166: Length of Elements of a Character Matrix

b
5 16


See also the description of the NLENG function.