Splitting data based on daynumber and get the belonging rows

2 ビュー (過去 30 日間)
Debbie Oomen
Debbie Oomen 2018 年 5 月 15 日
コメント済み: Guillaume 2018 年 5 月 15 日
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 件のコメント
Debbie Oomen
Debbie Oomen 2018 年 5 月 15 日
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 2018 年 5 月 15 日
Which version of matlab are you using? Any reason you're not using modern tools such as timetable, and possibly discretize, splitapply, etc.?

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeTime Series Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by