필터 지우기
필터 지우기

Determine begin and Endpoint of Interval with Threshold.

조회 수: 2 (최근 30일)
Ot
Ot 2014년 3월 3일
댓글: Image Analyst 2014년 3월 3일
I want to determine at which sample a curve in the movement of a player was started and at which sample the curve was stopped, to then calculate the magnitude of the total curve.
I have an input that shows the Index number of the midpoint of the curves(Mid_Angle(2x11 Matrix)). Around all these midpoints I want to know at which time the player started deviating his movement. Therefore, I have an Ang_Sample(1x1126), which displays the angle between the direction vectors of consecutieve samples.
I want to determine at which sample before the Midpoint of the angle the Ang_Sample went above 0.5 (and didn't go below 0.5 until MidPoint) to determine this as Beginpoint. And at which sample after the Midpoint the Ang_Sample went below 0.5 to determine this as Endpoint.
Right now I have a time interval (0.5s) which before and after I determine the first and last time to reach Ang_Sample above 0.5 . This method works well in most cases, but if the player makes an uncontrolled Angle or startes two angles shortly after each other I get problems.
d = 50 --> %number of samples interval before and after.
e = 0.5 --> %threshold for curve
for i= 1:length(Mid_Angle)
Ang_Abs = abs(Ang_Sample([Mid_Angle(1,i)-d]:[Mid_Angle(1,i)+d]));
Start_Ang(i) = find(Ang_Abs>e,1,'first')+(Mid_Angle(1,i)-d);
End_Ang(i) = find(Ang_Abs>e,1,'last')+(Mid_Angle(1,i)-d);
Total_Ang(i) = sum(Ang_Sample([Start_Ang(i)]:[End_Ang(i)]));
end
  댓글 수: 2
dpb
dpb 2014년 3월 3일
Often the way to attack such is to convert the values to binary where
A(A>th)=1;
A(A<=th)=-1;
Then diff() and find the +/-2 locations
Image Analyst
Image Analyst 2014년 3월 3일
Attach data that illustrates the problem - something we can use to test code on. Also put in a plot or graph or something so we can visualize what's going on.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by