How to get the time that a signal stays between certain values?

1 view (last 30 days)
I have acquired diesel engine rpm measurement data from CAN bus. I have the rpm values with a timestamp with about 50Hz frequency. Now I need to be able to define the time the engine rpm stays between certain upper and lower boundaries (in other words, how long the rpm stays on a certain rpm band). How to do that?

Accepted Answer

Walter Roberson
Walter Roberson on 8 Feb 2011
logicalvec = rpm >= lowerbound & rpm <= upperbound;
times_in_range = timestamps(logicalvec);
If you need to look for transition times, you can search
[false, logicalvec, false]
using strfind, looking for [0 1] to find the times it turns on, and looking for [1 0] for the times it turns off. Although strfind is for "strings", it turns out to work for these cases too.

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!