join
Joins the elements of a string or cell array of text into one piece of text.
Category: Language Fundamentals > Data Types
Syntax
newStr = join(str)
Joins the elements of str with a single space between them.
newStr = join(str, delimiter)
Joins them with delimiter between neighbors.
Description
join is the reverse of split. For a vector it concatenates all elements in order; the delimiter goes only between elements, never at the ends. The class of the result follows the class of the input, so a cell array of character vectors gives a character vector.
In MATLAB join also combines two tables by matching key variables, like a database join.
Input arguments
str- String array or cell array of character vectors.
delimiter- Text placed between elements. The default is one space.
Output arguments
newStr- A string when
stris a string array, or a character vector whenstris a cell array.
Example
Joining text
join(["a", "b", "c"], "-")
join({'one', 'two', 'three'})
join({'x', 'y'}, ', ')
Output
ans = "a-b-c"
ans = 'one two three'
ans = 'x, y'
Notes
MatLivre's join works on text and on two tables. A matrix of strings is joined across all elements in storage order, not row by row.