How to separate date and time into two tables?
10 views (last 30 days)
Hi, i am new to Matlab. I have a problem with separating imported data of date and time over the year (8760 values) into two tables. Imported data looks like this. Its a cell of data in one column and i need to separate it to date in one table and time in second table.
Thank you for any help.
Jing Xie on 25 Oct 2016
I hope the following piece of code may help you a little bit. I am not sure if the "table" in your question means the build-in func table in MATLAB. It is added at the end in case. The performance can be improved by using cellfun. As you are new to MATLAB, I guess the for loop structure may be more straightforward.
More Answers (1)
Marc Jakobi on 25 Oct 2016
Edited: Marc Jakobi on 25 Oct 2016
What format do you need the dates in? As strings? If not, I would recommend using datevec() to convert it to a matrix in the form:
[year, month, day, h, min, s]
so for example:
v = datevec(timestamp, 'mm/dd HH:MM:SS');
You can then separate v(1:3,:) (year, month & day) and v(4:6,:) (hours, minutes & seconds).