Hi community!
Thanks in advance for the help and suggestions I always receive. Now I jumo to my query!
So, I have a dataset as shown in the attached photo. I have a Start Time (1st column) and End Time (2nd column) of filling up of Gas Pump in Volume (3rd column). I want to resample every 1 minute based on Start Time and End Time. For the rest hours of the day, I want 0 values. At the end, I should have 1440 (24 x 60) values. I tried the "retime" function but was unsuccessful. Could anyone help me out?
Thanks again
Untitled.png

댓글 수: 2

Walter Roberson
Walter Roberson 2019년 8월 16일
Do you have a dataset() array from Statistics Toolbox? Do you have a table() from basic MATLAB? Do you have a timetable() ?
Alex
Alex 2019년 8월 16일
Yes Walter. I have attached the data in table format.

댓글을 달려면 로그인하십시오.

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2019년 8월 16일
편집: Andrei Bobrov 2019년 8월 16일

1 개 추천

T = fuel1(:,{'Start','Volume'});
T.Properties.VariableNames={'time','vol'};
T1=table;
T1.time = fuel1.End;
T1.vol = zeros(size(fuel1,1),1);
T = table2timetable(sortrows([T;T1]));
Tout = retime(T,'minutely','previous');

댓글 수: 6

Alex
Alex 2019년 8월 17일
Thanks, Andrei! It works like a charm.
Alex
Alex 2019년 8월 20일
편집: Alex 2019년 8월 20일
Dear Andrei,
How to proceed if we want some other sampling time, say 15minutes?
I tried to initalize 15minutes time in place of 'minutely' but I realized it is not correct.
Thanks
Use the 'dt' property
Tout = retime(T,'regular','previous','TimeStep',minutes(15))
You might want to think about the various "methods" and which would be best for your needs.
Alex
Alex 2019년 8월 20일
Great! I just figured out that. Thanks again Adam!
Adam Danz
Adam Danz 2019년 8월 20일
retime() is quite powerful. I have to reference the documentation frequently when I use it.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2019년 8월 16일

댓글:

2019년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by