Not all cell converte to double
Afficher commentaires plus anciens
Hello. I don't know how to convert cell to double and cut part of cell. This is my list:
list={'6.txt' '13.txt' '14.txt' '19.txt' '45.txt' '53.txt'};
and I need it without '.txt'.
Thanks in advance for any help.
Réponse acceptée
Plus de réponses (2)
Walter Roberson
le 27 Août 2013
cellfun( @(s) sscanf(s, '%d'), list)
1 commentaire
That's good side effect w/ cellfun in this case--the error on the '.txt' portion of the input string goes silently away w/o writing the explicit format string, Walter. I took the other way out to avoid the anonymous function definition but in production yours is probably preferable.
Azzi Abdelmalek
le 27 Août 2013
Modifié(e) : Azzi Abdelmalek
le 27 Août 2013
list=str2double(strrep(list,'.txt',''))
Catégories
En savoir plus sur Characters and Strings dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!