Percentage of time of a time series
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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](https://www.mathworks.com/matlabcentral/answers/uploaded_files/205317/QQ%E6%88%AA%E5%9B%BE20190221204433.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 Commenti
Risposte (1)
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.
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!