Method Reference: string.join

string: newstr = join (str)
string: newstr = join (str, delimiter)
string: newstr = join (str, dim)
string: newstr = join (str, delimiter, dim)

Combine string array elements.

newstr = join (str) combines the elements of str along the last dimension whose size is not 1, placing a single space between consecutive elements. That dimension is reduced to size 1.

newstr = join (str, delimiter) uses delimiter instead of a space. delimiter can be a string array, a character vector, or a cell array of character vectors. A scalar delimiter is placed between every pair of elements. An array delimiter supplies the text placed between consecutive elements and must have one fewer element than str along the joined dimension; its other dimensions must be 1 or match str.

newstr = join (str, dim) and newstr = join (str, delimiter, dim) combine the elements along dimension dim.

newstr has the size of str with the joined dimension reduced to 1. If any element being combined, or any delimiter placed between them, is a missing value, the corresponding element of newstr is a missing value.

Source Code: string

Example: 1

join combines the elements of a string array into a single string, placing a delimiter between them.

 parts = string ({'2024', '01', '15'})
parts =
  1x3 string array

    "2024"    "01"    "15"
 join (parts, '-')
ans =
  string

   "2024-01-15"