strvcat

Stacks text into a character matrix, skipping empty inputs.

Category: Language Fundamentals > Data Types

Syntax

S = strvcat(s1, s2, ...)

Returns a char matrix with one row per non-empty input.

Description

strvcat works like char or str2mat, with one difference: inputs that are empty do not produce a blank row, they are dropped. So strvcat('a', '', 'b') has two rows while char('a', '', 'b') has three.

It is a legacy function; prefer char when blank rows are wanted and string arrays when padding is not needed.

Input arguments

s1, s2, ...
Character vectors, strings or cell arrays of character vectors.

Output arguments

S
Character matrix padded with blanks to the length of the longest row.

Example

Empty input dropped

S = strvcat('one', '', 'three');
size(S)
S
Output
ans = 1×2

     2     5
S = 2×5 char array

    'one  '
    'three'

See also

char str2mat string cellstr