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.

답변 (2개)

Pan
Pan 2012년 4월 4일

0 개 추천

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."
Walter Roberson
Walter Roberson 2012년 4월 4일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

질문:

2012년 4월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by