sum up of different time series
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Chenyu Xue
am 27 Sep. 2018
Kommentiert: Chenyu Xue
am 27 Sep. 2018
i have several time series with corresponding measurement data, starting from different starting time,but have some overlapping time period between each other,or among several of them, i would like to sum up the corresponding measurement data if the time stamps occurrs in the time series, how do i do that ? For example, t1=[1,2,3,4], corresponding measurement m1=[5,4,3,6] t2=[2,3,4,5,6], corresponding measurement m2=[7,10,11,12,13] t3=[5,6,7], corresponding measurement m3=[80,20,36] t4=[1,2,3,4,5,6],corresponding measurement m4=[1,2,5,8,10,12]
I would like the output time series to be t=[1,2,3,4,5,6,7] and m equals the sum of the measurement where t=1,2,3,4,5,6,7 corresponds to in each of time series.
Thank you
0 Kommentare
Akzeptierte Antwort
jonas
am 27 Sep. 2018
Bearbeitet: jonas
am 27 Sep. 2018
I'm not a fan of indexed variable names, but OK. I assume the times are exactly and precisely defined, so that two dates in different vectors return true when compared. If they differ by even one millisecond, then you have to round or group with some tolerance.
ta = [t1 t2 t3 t4];
ma = [m1 m2 m3 m4];
[G,t] = findgroups(ta)
m = splitapply(@sum,ma,G)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Language Fundamentals 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!