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

조회 수: 2 (최근 30일)
Peter
Peter 2012년 4월 4일
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일
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일
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.

카테고리

Help CenterFile Exchange에서 Timing and presenting 2D and 3D stimuli에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by