Resample datetime to minute resolution

14 Ansichten (letzte 30 Tage)
Alex
Alex am 16 Aug. 2019
Kommentiert: Adam Danz am 20 Aug. 2019
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 Kommentare
Walter Roberson
Walter Roberson am 16 Aug. 2019
Do you have a dataset() array from Statistics Toolbox? Do you have a table() from basic MATLAB? Do you have a timetable() ?
Alex
Alex am 16 Aug. 2019
Yes Walter. I have attached the data in table format.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 16 Aug. 2019
Bearbeitet: Andrei Bobrov am 16 Aug. 2019
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 Kommentare
Alex
Alex am 20 Aug. 2019
Great! I just figured out that. Thanks again Adam!
Adam Danz
Adam Danz am 20 Aug. 2019
retime() is quite powerful. I have to reference the documentation frequently when I use it.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Preprocessing Data finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by