converting cell array to matrix

1 回表示 (過去 30 日間)
Gopalakrishnan venkatesan
Gopalakrishnan venkatesan 2015 年 6 月 16 日
コメント済み: Titus Edelhofer 2015 年 6 月 17 日
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 Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by