MATLAB Answers

Percentage of time of a time series

3 views (last 30 days)
Jian Teng
Jian Teng on 22 Feb 2019
Answered: Shunichi Kusano on 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)?

  0 Comments

Sign in to comment.

Answers (1)

Shunichi Kusano
Shunichi Kusano on 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.

  0 Comments

Sign in to comment.

Sign in to answer this question.