# 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.

라이선스가 부여된 사용자만 번역 문서를 볼 수 있습니다. 번역 문서를 보려면 로그인하십시오.

## Cell Arrays of Character Vectors

### Convert to Cell Array of Character Vectors

When you create character arrays from character vectors, all the vectors must have the same length. This often means that you have to pad blanks at the end of character vectors to equalize their length. However, another type of MATLAB® array, the cell array, can hold different sizes and types of data in an array without padding. A cell array of character vectors is a cell array where every cell contains a character vector. Cell array of strings is another frequently-used term for such a cell array. Cell arrays of character vectors provide a more flexible way to store character vectors of varying lengths.

Convert a character array to a cell array of character vectors. `data` is padded with spaces so that each row has an equal number of characters. Use `cellstr` to convert the character array.

```data = ['Allison Jones';'Development ';'Phoenix ']; celldata = cellstr(data) ```
```celldata = 'Allison Jones' 'Development' 'Phoenix' ```

`data` is a `3`-by-`13` character array, while `celldata` is a `3`-by-`1` cell array of character vectors. `cellstr` also strips the blank spaces at the ends of the rows of `data`.

The `iscellstr` function determines if the input argument is a cell array of character vectors. It returns a logical `1` (`true`) in the case of `celldata`:

```iscellstr(celldata) ```
```ans = 1 ```

Use `char` to convert back to a padded character array.

```chr = char(celldata) ```
```chr = Allison Jones Development Phoenix ```
```length(chr(3,:)) ```
```ans = 13 ```

For more information on cell arrays, see Access Data in a Cell Array.

### Functions for Cell Arrays of Character Vectors

This table describes the MATLAB functions for working with cell arrays of character vectors.

Function

Description

`cellstr`

Convert a character array to a cell array of character vectors.

`char`

Convert a cell array of character vectors to a character array.

`deblank`

Remove trailing blanks from a character array.

`iscellstr`

Return `true` for a cell array of character arrays.

`sort`

Sort elements in ascending or descending order.

`strcat`

Concatenate character arrays or cell arrays of character arrays.

`strcmp`

Compare character arrays or cell arrays of character arrays.

You can also use the following `set` functions with cell arrays of character vectors.

Function

Description

Set the intersection of two vectors.

Detect members of a set.

Return the set difference of two vectors.

Set the exclusive OR of two vectors.

Set the union of two vectors.

Set the unique elements of a vector.