parsing integers from directory list
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
mousomer Moussaffi
am 28 Okt. 2013
Beantwortet: Simon
am 28 Okt. 2013
I have a directory with files names:
1_d
3_kk
56_rr
I need to parse the list numbers from the file names. I need to output a numerical array
[1 3 56]
is there a simple way to do it?
0 Kommentare
Akzeptierte Antwort
Simon
am 28 Okt. 2013
Hi!
What du you have? An array of strings or a cell array? Are the numbers always in front of the file name?
Suppose you have a cell array C, try using regexp:
C2 = regexp(C, '(\d*)', 'tokens');
C2 = cellfun(@(x) x{1}, C2);
numbers = cellfun(@(x) str2double(x), C2);
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Search Path finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!