How I can convert a single char array in a table with 3 columns?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Anderson Oliveira
am 15 Jun. 2019
Kommentiert: Anderson Oliveira
am 15 Jun. 2019
I import a data from a web site with API, the data is a single char, 1-by-1, and I need to convert in a table with 3 columns, {year, month, data}
'Latitude (decimal degrees): 45.000Longitude (decimal degrees): 5.000Radiation database: PVGIS-CMSAFOptimal slope angle (deg.): Year Month Hh2005 Jan 45.52005 Feb 50.32005 Mar 1132005 Apr 1402005 May 1892005 Jun...
3 Kommentare
Walter Roberson
am 15 Jun. 2019
Assuming that the character vector is stored in a variable named DATA, please show us
DATA(1:50)
DATA(1:50)+0
Akzeptierte Antwort
Walter Roberson
am 15 Jun. 2019
Suppose you have the character vector stored in the variable S. Then:
info_struct = regexp(S, '(?<Year>\d{4})\s+(?<Month>[A-Za-z]{3})\s+(?<Hh>\d+(\.\d+)?)','names');
Year = str2double({info_struct.Year}.');
Month = vertcat(info_struct.Month);
Hh = str2double({info_struct.Hh}.');
YourTable = table(Year, Month, Hh);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu String Parsing 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!