How do I separate date and time of a raw date?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
aishah
am 30 Mär. 2018
Kommentiert: Walter Roberson
am 24 Feb. 2019
>> a = untitled.startDate(1:10)
a =
10×1 categorical array
2013-07-10 00:01:00.0
2013-07-17 00:01:00.0
2013-06-29 00:01:00.0
2013-07-17 00:01:00.0
2013-05-11 00:01:00.0
2013-05-31 00:01:00.0
2013-06-06 00:01:00.0
2013-08-31 00:01:00.0
2013-05-21 00:01:00.0
2013-08-06 00:01:00.0
>> a.Format = 'dd-MMM-yyyy'
Error using categorical/subsasgn (line 87)
Attempt to assign field of non-structure array.
3 Kommentare
Akzeptierte Antwort
Ahmet Cecen
am 30 Mär. 2018
Bearbeitet: Ahmet Cecen
am 30 Mär. 2018
arrayfun(@(x) strsplit(x,' '),string(a),'UniformOutput',false)
string(a) - this makes the data easily process-able, converts to a string array.
@(x) strsplit(x,' ') - this is a function that splits each string into parts whenever a space(' ') is located(which works for your case)
arrayfun - applies the above function to each "row" in the string array.
7 Kommentare
Weitere Antworten (1)
Peter Perkins
am 2 Apr. 2018
Don't do any of that.
You've read the timestamps in as datetimes. Don't fight that. Assuming you have a table T:
T.StartTime = timeofday(T.StartDate);
T.StartDate = dateshift(T.StartDate,'start','day);
6 Kommentare
Steph
am 24 Feb. 2019
I missteated my problem I think, I am doing regressions on the data that is collected on each of the specific days. Not on the dates or days themselves
Walter Roberson
am 24 Feb. 2019
Then you do not need to convert the dates + times or datetime objects to numeric. What you need to do is be able to group your data based upon date. You should have a look at splitapply() -- or convert the table to a timetable() object and use retime()
Siehe auch
Kategorien
Mehr zu Dates and Time finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!