Skip to Main Content Skip to Search
Product Documentation

cellstr - Create cell array of strings from character array

Syntax

c = cellstr(S)

Description

c = cellstr(S) places each row of the character array S into separate cells of c. Any trailing spaces in the rows of S are removed.

Use the char function to convert back to a string matrix.

Examples

Given the string matrix

S = ['abc '; 'defg'; 'hi  ']

S =
    abc
    defg
    hi

whos S
  Name      Size         Bytes  Class
  S         3x4             24  char array

The following command returns a 3-by-1 cell array.

c = cellstr(S)

c = 
    'abc' 
    'defg'
    'hi'

whos c
  Name      Size         Bytes  Class
  c         3x1            198  cell array

See Also

char | iscellstr | isstrprop | strings

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS