Convert Cell to String
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a cell array:
x = {'red' 'blue' 'green'}
I need to convert it to a string (looking for another way besides char). So the output would be:
red
blue
green
Thanks, Amanda
1 commentaire
Walter Roberson
le 2 Mai 2013
A single string with something (like a newline) between the parts? Or one string per cell entry? Is this for storing or for displaying? Could you indicate why using "char" is not desirable ?
Réponse acceptée
Cedric
le 2 Mai 2013
You could use something like:
s = sprintf('%s\n', x{:})
3 commentaires
Walter Roberson
le 2 Mai 2013
Note that this would have newline characters between the parts. I am not sure that is what the poster wants.
Plus de réponses (0)
Voir également
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!