MATLAB: How to combine three cells to output a date time

import timetxt import

My data is a .txt file with the first three fields beining the date time in the following format:
year doy timez
2017 100 04:03:00 Z
I used
D=datevec(datenum(year,1,doy));
D=datetime(D);
to get the year, month, day and 00:00:00
but I can't seem to get the timez to parse out. timez was imported into a table as a cell whereas year and doy were imported as double.

Best Answer

You would be better off fixing your import so that the whole date is imported as just one column of your table. For that, we need to know the original format of the file.
After the fact, probably the easiest to fix the mess is to recreate a string from your table variables and parse it with datetime. I'm using compose for that, which requires at least R2016b:
dates = compose('%4d %3d %s', yourtable.year, yourtable.day, string(yourtable.timez));
dates = datetime(dates, 'InputFormat', 'yyyy DDD HH:mm:ss Z', 'TimeZone', 'UTC')