How to use retime with duration in timetable?

조회 수: 4 (최근 30일)
Jennifer Pichl
Jennifer Pichl 2018년 4월 16일
답변: Peter Perkins 2018년 4월 19일
I want to change the timesteps from my timetable to 30 min steps. The source table uses 1 sec timesteps. Furthermore I want to create one table which agregates two values of the source table as Maximum and two others as Sum.
Therefore I made the following code:
fivdt=duration('00:00:00'):minutes(30):duration('23:59:59') %new Timestep
n5p1=TDHM18w1(:,{'kW','charger'}); %values for Maximum
TDHM18w121=retime(n5p1,fivdt,'max'); %table1
n5p2=TDHM18w1(:,{'medpower','nopower'}); %values to create sum
TDHM18w122=retime(n5p2,fivdt,'sum'); %table2
TDHM18w12=innerjoin(TDHM18w121,TDHM18w122); %join table1 and table2
If the source tabel would use datetime values and I would have used a datetime format for the new timesteps the retime works perfectly. Unfortunatly I don't have much expirience working with duration values. For my code I get the error: Input data must be numeric matrix with three columns, or three seperate numeric arrays. Do I need to change the values into datetime to use retime or is there another way to do it?

답변 (1개)

Peter Perkins
Peter Perkins 2018년 4월 19일

I am not sure what question you are asking. I think that you have a timetable whose row times are datetimes, i.e. absolute times, and you want a timetable whose row times are durations, i.e. relative times. There's no way to do that in one step because there's no way for retime to know where "zero" is.

You are going to need to do this in two steps:

  1. replace the datetime row times with durations by subtracting off your origin
  2. retime to 30min steps

So something like

tt.Time = tt.Time - dateshift(min(tt.Time)m,'start','day);
tt = retime(tt,minutes(0:30:1440),'sum')

카테고리

Help CenterFile Exchange에서 Timetables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by