Calculating duration in large dataset based on conditions
Ältere Kommentare anzeigen
Hi,
I have a large dataset with 3 columns (datetime, Var1 & Var2). The data is over a month with a datapoint every 2 seconds.
I want to determine the duration when Var2 is above 1000 and the average value of Var1 when this is the case. The problem I have is not counting the duration from one true datapoint to the next true point (Var2 >1000).
Can someone help me with some code to determine this? Alternatively, a different way of determining the same thing would be appreciated.
Thanks!
2 Kommentare
SALAH ALRABEEI
am 17 Jun. 2021
Do you mean the duration ( sum of all datapoints corresponding to the Var2>2!)
Assuming I got what you mean!,
index = find(Var2 > 1000);
duration = sum(2* length(index)); % length(index) is the number of points where each points is two seconds
Var1_Avg = mean(Var1(index));
Matt R
am 17 Jun. 2021
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

