Splitting data based on daynumber and get the belonging rows

2 views (last 30 days)
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
Debbie Oomen
Debbie Oomen on 15 May 2018
yes it does with the original data, but that is why I only used to 1:3 columns. To only get the date and ignore the times. The dates are unique but the time is not so therefor I only used these columns. To split the data into days
Guillaume
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.?

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!