Good morning, MATLAB universe. I'm ready to beat my head into the wall over this, so any assistance/information would be appreciated. I have the following snippet of a 14244-by-8 cell array:
'01:08:26' 'AM' 'a' '101017' '4152' '176036' '0.0' '0.0'
'01:10:28' 'AM' 'a' '102454' '4876' '180400' '0.0' '0.0'
'11:00:09' 'PM' 'b' '106776' '1249480' '29113700' '1.9' '23.1'
'11:00:09' 'PM' 'b' '106832' '1529932' '30648184' '2.3' '47.5'
'11:01:10' 'PM' 'b '106776' '1252528' '29646212' '1.9' '11.1'
'11:01:10' 'PM' 'b' '106832' '1534468' '31182744' '2.3' '22.8'
'11:02:11' 'PM' 'b '106776' '1302992' '31376876' '1.9' '7.6'
'11:02:11' 'PM' 'c' '106832' '1538680' '32263188' '2.3' '15.2'
'11:03:12' 'PM' 'c' '106776' '1304560' '32109080' '1.9' '5.7'
'11:03:12' 'PM' 'c' '106832' '1539608' '32271412' '2.3' '11.4'
'11:04:13' 'PM' 'd' '106776' '1307908' '32254544' '1.9' '4.6'
'11:04:13' 'PM' 'd' '106832' '1543748' '32284776' '2.3' '9.2'
'11:05:14' 'PM' 'd' '106776' '1307932' '32263796' '1.9' '3.8'
'11:05:14' 'PM' 'd' '106832' '1544500' '32293000' '2.3' '7.7'
'11:06:16' 'PM' 'd' '106776' '1308228' '32274076' '1.9' '3.3'
'11:06:16' 'PM' 'd' '106832' '1549092' '32319728' '2.3' '6.7'
Individually, I can separate these into cells based on the 3rd Column easily to manipulate the time in the 1st Column, which is where the problem starts. Since this is just part of the whole, each letter designator goes on for multiple days in the 12-hr (AM/PM) format. I determined it would be easiest to convert this to 24-hr format, so I came up with a simple 'if' statement to accomplish that task based on the 2nd Column (if PM, add 12-hrs sort of thing).
What I saw, though, was an issue adding 12-hours to the time (MATLAB seemed to treat it as a character array), which I addressed first by attempting to convert the 1st Column into a duration array while still inside the larger cell array. MATLAB didn't like that. My second attempt centered around extracting the 1st Column, converting it to a duration array, and concatenating it with the original cell array using horzcat, strcat, or A = [duration_array original_array], which MATLAB wasn't happy about either.
None of the research I did turned up anything conclusive, so at this point, I'm not even sure if a duration array can be concatenated with a non-duration array. Does anyone know of an alternative to my concatenation method(s)? If not, any recommendations on a direction in which to proceed? For a bit more background, note that based on the data format, it was read into MATLAB (using importdata) as a cell array thanks to having numeric and non-numeric data. Frankly, I am nowhere near a savvy enough scripter to know if that makes a difference.
Best Answer