converting cell array to matrix

3 次查看(过去 30 天)
I have a cell array a = {'a' , 'b' , 'c' ,'d' , 'e'}
I need to convert a cell array to matix with ','(comma in between)
my answer should be a = a,b,c,d,e
how can i do it?
thanks a lot
  1 个评论
Guillaume
Guillaume 2015-6-16
While technically
a = 'a,b,c,d,e';
is a matrix. Calling it a char array or a string would make more sense.
It certainly begs the question: do you understand the differences (or lack of) between a matrix of numbers and a matrix of characters?

请先登录,再进行评论。

采纳的回答

Andrei Bobrov
Andrei Bobrov 2015-6-16
编辑:Andrei Bobrov 2015-6-16
a = {'a' , 'b' , 'c' ,'d' , 'e'};
a = sprintf('%c,',[a{:}]);
a = a(1:end-1);
  5 个评论
Guillaume
Guillaume 2015-6-16
See my comment and look at the documentation of strjoin.
Titus Edelhofer
Titus Edelhofer 2015-6-17
@Guillaume: nothing wrong with strjoin except that I did not know it ;-)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by