How can I change cell array into strings
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
A ["an"] ["bn"] ["cn"] ["sb"]
How can I convert A into like this
'an' 'bn' 'cn' 'dn'
0 commentaires
Réponse acceptée
KL
le 2 Nov 2017
Modifié(e) : KL
le 2 Nov 2017
cc = cellfun(@num2str,c,'uni',0)
if you have both string and numerics in cell array and you want to convert them all to char,
cc = cell(size(c));
for k=1:numel(c)
if(isnumeric(c{k}))
cc{k} = num2str(c{k});
elseif (isstring(c{k}))
cc{kk}= char(c{k});
%and so on
end
end
Another idea is,
cellfun(@(x) char(string(x)),c,'uni',0)
0 commentaires
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!