converting cell array to matrix

조회 수: 3 (최근 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 CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by