converting cell array to matrix

1 vue (au cours des 30 derniers jours)
Gopalakrishnan venkatesan
Gopalakrishnan venkatesan le 16 Juin 2015
Commenté : Titus Edelhofer le 17 Juin 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 commentaire
Guillaume
Guillaume le 16 Juin 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?

Connectez-vous pour commenter.

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by