Percentage of time of a time series

9 次查看(过去 30 天)
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)?

回答(1 个)

Shunichi Kusano
Shunichi Kusano 2019-2-22
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.

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by