How can i select daily data with a 15 min partition?

3 ビュー (過去 30 日間)
Enrique Escrig
Enrique Escrig 2020 年 5 月 5 日
コメント済み: Enrique Escrig 2020 年 5 月 6 日
Hi!!
I have a timetable with data of days with a periodicity of 15 min and I want to select different days. At the time of selecting the days that I want, only get the data for the day at 00:00. I want you to take all the data from those selected days.
Thanks in advance
  1 件のコメント
KSSV
KSSV 2020 年 5 月 5 日
Read about interp1. Generate your required time arrays and do inteprolation.

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

採用された回答

Peter Perkins
Peter Perkins 2020 年 5 月 5 日
These two things
"only get the data for the day at 00:00. I want you to take all the data from those selected days"
seem contradictory.
It sounds like you have a timetable that spans multiple days, with 15min time steps. If you want to select only some of those days, and they are contiguous, use timerange as Steve suggests. If the days are not contiguous, use ismember to create a logical vector from the timetable's row times, then use that as a row subscript to select the days of interest.
If you additionally only want the "midnight" rows on those selected days, use timeofday on the timetable's row times to again create a logical vector for subscripting.
If, on the other hand, you want to somehow aggregate all the data from each day into one row whose timestamp is at midnight, use retime with an aggregation, as KSSV suggests.
It would help if you gavce a short clear example of what you have and what you want.
  3 件のコメント
Peter Perkins
Peter Perkins 2020 年 5 月 5 日
Right. You are giving the timetable a datetime subscript, and it selects rows with exact matches. You need to create a logical subscript. Try this:
days_select_mask = ismember(dateshift(TT_all_data.Time,'start','day'),days_select);
TT_days_select = TT_all_data(days_select,:)
Anotehr possibility would be to set all your days_to_select to noon, and use withtol and a tolerance of 12 hours. That's kind of a misuse of withtol, though.
Enrique Escrig
Enrique Escrig 2020 年 5 月 6 日
It works perfectly, thank you very much.

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

その他の回答 (1 件)

Steven Lord
Steven Lord 2020 年 5 月 5 日
Index into your timetable with a timerange.
x = randn(100, 1);
N = datetime('now');
t = N + minutes(60*x);
tt = timetable(t, x);
R = timerange(N, N + minutes(15))
next15Minutes = tt(R, :)
To check, compute what x should be from the RowTimes of next15Minutes.
x2 = minutes(next15Minutes.t - N)/60; % Reversing how we created t originally
next15Minutes.x-x2 % Should be close to the zero vector

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by