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 CenterFile Exchange에서 Time Series Events에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by