How do I find the Time at which an Event occurs?

For my data, I have Throttle Position vs. Time. (sampled at 80Hz).
For most of the run, throttle position is varying around 30%, then near the end of the run throttle is quickly advanced to 100% (sometimes to 150%).
I need to find the time at which the throttle is starting to advance to 100%.
Here's what I'm trying, but I can't get it to work for me (etr_cmd is Throttle Position):
for x = 1:size(etr_cmd,1)
wave_start = diff(etr_cmd);
if (wave_start == 1.0)
time_row1 = x;
end
end
Any Help would be greatly appriciated.

Answers (2)

In my studies, I use a function named "GetSecs", which returns "the time in seconds (with high precision)". Plus, "GetSecs uses the highest precision realtime clock on each operating system."
Will the change in throttle really be 1.0 exactly? Is your data quadrature encoded or something like that? It would seem more likely that etr_cmd would become 1.0 or greater when the throttle reaches 100%, but that the immediately previous position could be anywhere from ~0.3 upwards, leading to a diff() of 0.7 downward ??
find(etr_cmd >= 1.0, 1)
would seem like what you want.

Asked:

on 4 Apr 2012

Community Treasure Hunt

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

Start Hunting!