Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

strjoin

Join strings in cell array into single string

Syntax

Description

example

str = strjoin(C) constructs the character vector, str, by linking each character vector in the cell array, C, with a single space.

example

str = strjoin(C,delimiter) constructs the character vector, str, by linking each character vector of C with the elements in delimiter.

Examples

collapse all

Join List of Words with Whitespace

Join individual character vectors in a cell array of character vectors, C, with a single space.

C = {'one','two','three'};
str = strjoin(C)
str =

one two three

Join Cell Array of Character Vectors

C = {'Newton','Gauss','Euclid','Lagrange'};
str = strjoin(C,', ')
str =

Newton, Gauss, Euclid, Lagrange

Join Character Vectors with Multiple Different Delimiters

Specify multiple different delimiters in a cell array of character vectors. The delimiter cell array must have one fewer element than C.

C = {'one','two','three'};
str = strjoin(C,{' + ',' = '})
str =

one + two = three

Input Arguments

collapse all

C — Input text1-by-n cell array of character vectors

Input text, specified as a 1-by-n cell array of character vectors. Each element in the cell array must contain a character vector.

Example: {'The','rain','in','Spain'}

Data Types: cell

delimiter — Delimiting characterscharacter vector | 1-by-n cell array of character vectors

Delimiting characters, specified as a character vector or a 1-by-n cell array of character vectors.

  • If delimiter is a character vector, then strjoin forms str by inserting delimiter between each element of C. The delimiter input can include any of these escape sequences:

    \\

    Backslash

    \0

    Null

    \a

    Alarm

    \b

    Backspace

    \f

    Form feed

    \n

    New line

    \r

    Carriage return

    \t

    Horizontal tab

    \v

    Vertical tab

  • If delimiter is a cell array of character vectors, then it must contain one fewer element than C. Each element in the cell array must contain a character vector. strjoin forms str by interleaving the elements of delimiter and C. All characters in delimiter are inserted as literal text, and escape sequences are not supported.

Example: ', '

Example: {',',' '}

Data Types: char | cell

See Also

| | |

Introduced in R2013a

Was this topic helpful?