Q:

Using textscan() in Octave... How to properly format?

I have a data set on disk that I'm reading line by line, and I would like to convert one of the columns of data into a vector of floats (with a range of 0-23.99999) (for that day).
The data looks something like the following:
2010/01/01,00:00:00.979131, 27.4485,  51.9362, 14.8,  6
2010/01/01,00:00:01.021977, 27.5149,  51.9375, 16.0,  6
2010/01/01,00:00:01.074032, 27.4797,  51.9446, 14.5, 10
2010/01/01,00:00:01.663689, 25.8441,-152.8141, 14.6,  6
2010/01/01,00:00:01.639541, 25.8744,-152.6122,  1.5,  5
2010/01/01,00:00:02.232099, -2.2447,  11.5023, 18.8,  6
2010/01/01,00:00:02.256351, -0.8135,  27.3139, 17.7,  5
2010/01/01,00:00:02.306734, -2.7797,  28.5109, 26.0,  5
2010/01/01,00:00:02.620765, 25.6656,-154.2029, 26.2,  9
2010/01/01,00:00:02.658495, 25.6698,-154.2157, 23.0,  6
2010/01/01,00:00:02.731266, -5.7106, 126.4517,  3.6,  5
2010/01/01,00:00:02.787495, -5.7138, 126.5210, 24.4,  8
2010/01/01,00:00:02.811636, -3.2453, 124.6919, 21.1,  8

column 2 (e.g., 00:00:00.979131) is of interest and I would like to do something like
setenv GNUTERM 'x11';
fid = fopen('myfile.txt', 'r');
m = textscan(fid, '%d%d%d%d/%d%d/%d%d, %d%d:%d%d:%d%f, %f, %f, %f, %d');
mx = m(:, 5); %here, I would expect to grab 14.8, 16.0, etc
my = m(:, 2) / 24.0; %here, all data from timestamp column (00:00:00.979131, for ex)
plot(mx, my);

The issue is that the string I pass to textscan is malformatted for my data.
The formatting of that number is "hrs:minutes:seconds", in military time.
How can I access/convert the values for the vars mx, or my?
Thanks,
jml

A:

The output of textscan is a cell array. If you use the command in your answer:
m = textscan(fid, '%d/%d/%d %d:%d:%f %f %f %f %d', 'delimiter', ',');

Then to get a vertical vector of 14.9, 16.0, 14.5:
MyNinthField = m{9};

MyNinthField =
14.8000
16.0000
14.5000
14.6000
 1.5000
18.8000
17.7000
26.0000
26.2000
23.0000
 3.6000
24.4000
21.1000

Then, to get the timestamp (seconds since the beginning of the day):
Hours = double(m{4});
Minutes = double(m{5});
Seconds = m{6};

For Seconds double is not needed, because m{6} is already double. However, m{4} and m{5} are both int32.
To get the time of the day in seconds, all you need is:
TimeOfDayInSeconds = 3600*Hours+60*Minutes+Seconds;

TimeOfDayInSeconds =
0.97913
1.02198
1.07403
1.66369
1.63954
2.23210
2.25635
2.30673
2.62077
2.65849
2.73127
2.78749
2.81164

If you didn't do type conversion from int32 to double, Octave would truncate the values to integers. MATLAB however does not even allow the sum between integer and double arrays.
Hope this helps.

