Import & modify date data in MATLAB
Posted
by niko
on Stack Overflow
See other posts from Stack Overflow
or by niko
Published on 2010-05-20T13:55:39Z
Indexed on
2010/05/20
14:40 UTC
Read the original article
Hit count: 234
I have a .csv file with records written in the following form:
2010-04-20 15:15:00,"8.9915176259e+00","8.8562623697e+00"
2010-04-20 15:30:00,"8.5718021723e+00","8.6633827160e+00"
2010-04-20 15:45:00,"8.4484844117e+00","8.4336586330e+00"
2010-04-20 16:00:00,"1.1106980342e+01","8.4333062208e+00"
2010-04-20 16:15:00,"9.0643470589e+00","8.6885660103e+00"
2010-04-20 16:30:00,"8.2133517943e+00","8.2677822671e+00"
2010-04-20 16:45:00,"8.2499419380e+00","8.1523501983e+00"
2010-04-20 17:00:00,"8.2948492278e+00","8.2884797924e+00"
From these data I would like to make clusters - I would like to add a column with number indicating the hour - so in case of the first row a value 15 has to be added in a new row.
The first problem is that calling a function
[numData, textData, rawData] = xlsread('testData.csv')
creates an empty matrix numData and one-column textData and rawData structures.
Is it possible to create any template which recognizes a yyyy, MM, dd, hh, mm, ss values from the data above?
What I would basically like to do with these data is to categorize the values by hours so from the example row of input:
2010-04-20 15:15:00,"8.9915176259e+00","8.8562623697e+00"
update 1: in Matlab the line above is recognized as a string:
'2010-04-26 13:00:00,"1.0428104753e+00","2.3456394130e+00"'
I would want this to be the output:
15, 8.9915176259e+00, 8.8562623697e+00
update 1: a string has to be parsed
Does anyone know how to parse a string and retrieve a timestamp, value1 (1.0428104753e+00) and value2 (2.3456394130e+00) from it as separate values?
© Stack Overflow or respective owner