I have this cell array
>> FooCellArray
FooCellArray =
1×7 cell array
Columns 1 through 4
{'Foo1'} {'Foo2'} {'Foo3'} {'Foo4'}
Columns 5 through 7
{'Foo5'} {'Foo6'} {'Foo7'}
cell2mat() converts the array into a character array instead of a 1x7 or 7x1 matrix of 'Foo1' ... 'Foo7'.
>> (cell2mat(FooCellArray))'
ans =
28×1 char array
'F'
'o'
'o'
'1'
'F'
'o'
'o'
'2'
'F'
'o'
'o'
'3'
'F'
'o'
'o'
'4'
....
Why?
cell2matis doing precisely the correct thing as documented here. Eachcellelement ischarvector of size 1xN. Your overallcellarray is 1xN.cell2matconcatenates the contents of every cell in the "natural" direction as defined by the shape of thecellarray. Your originalcelllooks a bit like this:The effect of
cell2matis basically as if you removed the{}, so you're left withAnd therefore this gets concatenated into a single
charvector'Foo1Foo2'.Compare with vectors of
doubleinstead of vectors ofchar: