Splitting data based on daynumber and get the belonging rows
2 views (last 30 days)
Show older comments
I have a dataset with datenum values in one column and another column with numbers(counts). The datenum values are the date + time. I need to calculate certain values per day and afterwards per specific timeframe in a day. I have been able to split this data by day using the following code:
TimeData = (:,1);
CountsData = (:,2);
TimeDataDay = datevec(TimeData);
TimeDataDay = TimeDataDay (:,1:3); %only return the date
UniqueDate = unique(TimeDataDay);
DataDay = [TimeDataDay, CountsData] %returns only date vs counts
DataDay1 = UniqueDate(1,:)
[row,~] = find(DataDay == DateDay1)
DataD1 = DataDay(row,:);
So now DataD1 is the date vs the counts. It does not display the time. However, I need to get the date + time vs the time. Is there a way to do this?
3 Comments
Guillaume
on 15 May 2018
Which version of matlab are you using? Any reason you're not using modern tools such as timetable, and possibly discretize, splitapply, etc.?
Answers (0)
See Also
Categories
Find more on Time Series Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!