我有:
S = ['abc '; 'defg'; 'hi ']; % S is a 3x4 char
c = cellstr(S) % c is a 3x1 cell
c =
'abc'
'defg'
'hi'
我如何从c获得S?也就是说,cellstr()
的倒数是什么?
答案 0 :(得分:2)
您可以使用char(c)
:
S = ['abc '; 'defg'; 'hi ']; % S is a 3x4 char
c = cellstr(S) % c is a 3x1 cell
c =
'abc'
'defg'
'hi'
S2 = char(c) % S2 is a 3x4 char
all(all(S == S2))
ans =
1 % S and S2 are identical