converting cell array to matrix
5 views (last 30 days)
Show older comments
Gopalakrishnan venkatesan
on 16 Jun 2015
Commented: Titus Edelhofer
on 17 Jun 2015
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 Comment
Guillaume
on 16 Jun 2015
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?
Accepted Answer
Andrei Bobrov
on 16 Jun 2015
Edited: Andrei Bobrov
on 16 Jun 2015
a = {'a' , 'b' , 'c' ,'d' , 'e'};
a = sprintf('%c,',[a{:}]);
a = a(1:end-1);
5 Comments
Titus Edelhofer
on 17 Jun 2015
@Guillaume: nothing wrong with strjoin except that I did not know it ;-)
More Answers (0)
See Also
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!