Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

# Data not being filtered out by threshold

조회 수: 2 (최근 30일)
Joshua Isherwood 2017년 5월 10일
마감: MATLAB Answer Bot 2021년 8월 20일
I am trying to create touch down and take off events on my centre of pressure data, however the threshold I have created seems to consistently come in one frame too early.
The threshold is allowing data below (-0.51) the set value (<2) through. Even when the threshold is increased this is happening. So i am constantly left with a negative value as first touch down before the actual touch down occurs one frame later.
This is the code i am using to create the events:
Air = zeros(length(mm3),1);
for n = 1:length(mm3)
if mm3(n,2) < 2
Air(n,1) = 1;
end
end
Edges = diff(Air); % Steigung kennzeichnet aufsteigende und abfallende Kante
TOPressure = find(Edges==1); % Absprungzeitpunkte
TDPressure = find(Edges==-1);
plot(mm3(:,2))
TOPressure = TOPressure(5:55,1);
TDPressure = TDPressure(5:55,1);
TOPressure = TOPressure(2:47,1);
TDPressure = TDPressure(1:46,1);
##### 댓글 수: 2없음 표시없음 숨기기
Jan 2017년 5월 10일
I do not see a relation between the description and the code. The code does not contain any threshold. What does "seems to come one frame too early" exactly mean? Which variable is concerned?
By the way: You can create Air directly without pre-allocation and a loop:
Air = double(mm3(:, 2) < 2);
Joshua Isherwood 2017년 5월 11일
The threshold would be this line : if mm3(n,2) < 2 so the code should create the events TDPressure and TDPressure at the first values exceeding 2.
Sorry a little vague on that part. The variable is the centre of pressure measured during running so the events are supposed to be created during initial ground contact (TDPressure) and final ground contact (TOPressure) however the events are being created one frame too early with the foot still in the air.
So it allows one frame of data < 2 through and creates the events then as apposed to the following frame which is actually > 2.
Have included two files, mm3 which shows that the initial contact occurs at frame 206 with a value > 2, then the TDPressure which has the initial contact occurring at 205 with a value at < 2.

### 답변 (1개)

Santhana Raj 2017년 5월 11일
If you see the help of diff, it says: diff(X), for a vector X, is [X(2)-X(1) X(3)-X(2) ... X(n)-X(n-1)].
So, in your case, 80th element of Air is actually 1. And when you use diff, 79th element of TOPressure is Air(80)-Air(79), (which is actually the edge).
##### 댓글 수: 2없음 표시없음 숨기기
Joshua Isherwood 2017년 5월 15일
So my issue is with the diff not with the air? How am i best resolving the issue?
Santhana Raj 2017년 5월 22일
Yes. It looks so.
Easiest way out would be to add 1 to the result of find. another way is to adjust the result of diff by one position.

이 질문은 마감되었습니다.

### Community Treasure Hunt

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

Start Hunting!