Matlab char array for cell array

Let's say I have a character array that looks like ...

   hello
   hillo
   hello

      

and I would like to convert them to a cell array which will be the same as ...

     A = {'hello';'hillo';'hello'}

      

The way I would go about it, I tried using mat2cell, but it seems like it just put everything in one big cell and didn't actually break them up. So say for example with the original character array the output, for example if I put

     A = mat2cell(arrayofchars)

     [3x5 char]

    instead of the preferred output of...

     'hello'
     'hillo'
     'hello'

      

Sorry if I didn't explain my problem very well! I'm brand new to Matlab!

Hooray!

+3


source to share


1 answer


You can use a function cellstr

for this as suggested by Divakar .



A = ['hello'
     'hillo'
     'hello']

C = cellstr(A)
C =     
    'hello'
    'hillo'
    'hello'

      

+2


source







All Articles