how to split character data in string and double?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I'm having difficulties separating character arrays. I want to split the char strings below and retrieve the numeric values.
'Time 12:57:33'
'Temp. T2 [deg.C] = 36.6'
'Solar Irradiance [kW/m^2] 0.857101'
Can anybody help me? Im new to Matlab and I know this should be an easy task, but im having quite some trouble with it.
Thanks in advance, greetings Boudewijn
0 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 28 Feb. 2014
Bearbeitet: Andrei Bobrov
am 28 Feb. 2014
c = {'Time 12:57:33'
'Temp. T2 [deg.C] = 36.6'
'Solar Irradiance [kW/m^2] 0.857101'}
regexp(c,'(\d*:)*\d*(\.\d*)*$','match')
4 Kommentare
Weitere Antworten (1)
Azzi Abdelmalek
am 28 Feb. 2014
Bearbeitet: Azzi Abdelmalek
am 28 Feb. 2014
str='Time 12:57:33'
out=regexp(str,'\d+(\.)?(\d+)?','match')
1 Kommentar
Azzi Abdelmalek
am 28 Feb. 2014
Bearbeitet: Azzi Abdelmalek
am 28 Feb. 2014
If your data are stored like:
v={'Time 12:57:33','Temp. T2 [deg.C] = 36.6','Solar Irradiance [kW/m^2] 0.857101';'Time 12:57:33' ,'Temp. T2 [deg.C] = 36.6','Solar Irradiance [kW/m^2] 0.857101'}
out=regexp(v,'[\d:]+(\.)?(\d+)?$','match')
out=[ [out{:,1}]' [out{:,2}]' [out{:,3}]']
Siehe auch
Kategorien
Mehr zu Data Type Conversion 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!