Language Reference


CONCAT Function

CONCAT (argument1, argument2 <, …, argument15> );

The CONCAT function produces a character matrix that contains elements that are the concatenations of corresponding elements from each argument. The CONCAT function accepts up to 15 arguments, where each argument is a character matrix or a scalar.

All nonscalar arguments must have the same dimensions. Any scalar arguments are used repeatedly to concatenate to all elements of the other arguments. The element length of the result equals the sum of the element lengths of the arguments. Trailing blanks of one matrix argument appear before elements of the next matrix argument in the result matrix.

For example, suppose you specify the following matrices:

b = {"AB" "C ",
     "DE" "FG"};
c = {"H " "IJ",
     " K" "LM"};

The following statement produces a new $2 \times 2$ character matrix, a:

a = concat(b, c);
print a;

Figure 25.76: Elementwise Concatenation of Strings

a
ABH C IJ
DE K FGLM



Quotation marks (") are needed only if you want to embed blanks or maintain uppercase and lowercase characters. You can also use the addition operator to concatenate character operands.