Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

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            294  cell array

See Also

iscellstr, strings, char, isstrprop

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS