How to read a complex alphanumeric string or cell
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Stefano Alberti
am 10 Feb. 2016
Bearbeitet: Stefano Alberti
am 11 Feb. 2016
Hi, I've some troubles to generate a code to read a complex (for me) alphanumeric string (or cell).
I've a cell (4000x1) with a text file like this: 'Daily_cum_2013_05_30_09_59__2013_05_31_10_05.asc' I want to separate the two dates (2013-05-30 09:59 and 2013-05-31 10:05) and convert it to a date format.
I tryed with sscanf, strread, textscan comands, but I don't succeed. Like:
test = sscanf(text,'%*s %d'); %to not consider the first part of text
but it doesn't work.
Is it so difficult ?
Thanks in advance
Stefano
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 10 Feb. 2016
If you have a cell array C of strings to split this way, then
sC = regexp(C, '__', 'split');
will be a cell array the same size as C, in which each element is a 1 x 2 cell array of strings. If you then
sC = vertcat(sC{:});
then the result would be an N x 2 cell array in which the columns are the two sides of the '__'
0 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!