Azzera filtri
Azzera filtri

Percentage of time of a time series

7 visualizzazioni (ultimi 30 giorni)
Jian Teng
Jian Teng il 22 Feb 2019
Risposto: Shunichi Kusano il 22 Feb 2019
I have a series of RPM measurement and each measurement corresponse to a time. If I plot the time series of my RPM, it will looks like this:
QQ截图20190221204433.png
The measurements are only recorded when the value are chaning, for example if 21:01 is 0 RPM, and 21:02 is also 0 RPM, the data on 21:02 will not be recorded.
My goal is figure out how to determine the percentage of the time, when the RPM is lower than 1, during the period (8PM to 5AM)?

Risposte (1)

Shunichi Kusano
Shunichi Kusano il 22 Feb 2019
How about using diff function to your time vector data? The following is an example. The details need to be modified.
% time_vec: time stamp in order when RPM value changed.
% val_vec: RPM values at time_vec
d_time = diff(time_vec);
total_duration = sum(d_time);
percentage = 100 * sum(d_time(val_vec < 1)) / total_duration;
if time_vec does not include the time of your targeted start-time and end-time, you need to insert them to time_vec as well as the corresponding values to val_vec.
hope this helps.

Categorie

Scopri di più su Programming in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by