# Documentation

### This is machine translation

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

# strings

Create array of strings with no characters

## Description

str = strings returns a string with no characters. For more information on string arrays, see Characters and Strings.

example

str = strings(n) returns an n-by-n array of strings with no characters.

example

str = strings(sz1,...,szN) returns a sz1-by-...-by-szN array of strings with no characters, where sz1,...,szN indicate the size of each dimension. For example, strings(2,3) returns a 2-by-3 array of strings.

example

str = strings(sz) returns an array of strings with no characters, where size vector sz defines size(str). For example, strings([2,3]) returns a 2-by-3 array of strings.

## Examples

collapse all

str = strings(4)
str =

4×4 string array

""    ""    ""    ""
""    ""    ""    ""
""    ""    ""    ""
""    ""    ""    ""

str = strings([2,6])
str =

2×6 string array

""    ""    ""    ""    ""    ""
""    ""    ""    ""    ""    ""

Create an array of empty strings that is the same size as an existing array.

A = [1 2 3; 4 5 6];
sz = size(A);
str = strings(sz)
str =

2×3 string array

""    ""    ""
""    ""    ""

It is a common pattern to combine the previous two lines of code into a single line:

str = strings(size(A));

You can use strings to preallocate the space required for a large string array.

## Input Arguments

collapse all

Size of a square array, specified as a nonnegative integer.

• If n is 0, then str is an empty array.

• If n is negative, then strings treats n as 0.

Data Types: double | single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Size of each dimension, specified as separate nonnegative integer arguments.

• If the size of any dimension is 0, then str is an empty array.

• If the size of any dimension is negative, then strings treats it as 0.

• Beyond the second dimension, strings ignores trailing dimensions with a size of 1. For example, strings(3,1,1,1) produces a 3-by-1 vector of strings with no characters.

Data Types: double | single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Size of each dimension, specified as a row vector of nonnegative integers. Each element of this vector indicates the size of the corresponding dimension:

• If the size of any dimension is 0, then str is an empty array.

• If the size of any dimension is negative, then strings treats it as 0.

• Beyond the second dimension, strings ignores trailing dimensions with a size of 1. For example, strings([3,1,1,1]) produces a 3-by-1 vector of strings with no characters.

Example: sz = [2,3,4] creates a 2-by-3-by-4 array.

Data Types: double | single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64