can someone explain this code?

조회 수: 1 (최근 30일)
Bhargavi
Bhargavi 2012년 6월 28일
x1= (Subject5_leftfall_1(:,44)-Subject5_leftfall_1(10,44));
x1_Y=find(x1 >= mean(x1(10:300))+3*std(x1(10:300)));
plot(x1(x1_Y(1):length(x1)),'g')
S5_Peak_left_1= max(x1(x1_Y(1):x1_Y(1)+70));
S5_index_peak_left_1=find(x1(x1_Y(1):x1_Y(1)+70)==S5_Peak_left_1)
I don't know what x1_Y is trying to do. Also, I don't know what the last two lines of the code are trying to do.

채택된 답변

Geoff
Geoff 2012년 6월 28일
x1_Y is an array of indices. You're doing a boolean test on x1(10:300) to determine if a point is an outlier. That is, it is larger than (or equal to) 3 standard deviations over the mean. Actually, this is only testing outlying peaks - it's not testing standard deviations below the mean. Anyway, that's what find does. It takes a boolean expression and returns the index of every true value. So, if I had an array:
x = [ 0 1 1 0 0 0 1];
Then find(x) would return:
ans = [2 3 7]
Now, the last two lines are looking for the largest x1 value between the first detected outlier and 70 positions ahead. It then asks for the indices of any value equal to that in the same range. However, this is a little bogus. If there are two identical maximum peaks there, then find will return an array. I think this code intends to get a single index for the largest value. This is more correct:
[S5_Peak_left_1, S5_index_peak_left_1] = max( x1( x1_Y(1):x1_Y(1)+70 ) );
This code might still be wrong, depending on the reason for searching that 71-element range. Remember the index x1_Y is indexing into a slice of x1: (10:300), so if x1_Y(1) is 10, that means the actual position of that outlier in x1 is 20.
Hope that helps a little.
  댓글 수: 1
Bhargavi
Bhargavi 2012년 6월 29일
Thanks a bunch Geoff. Also, there are no data on the first 9 lines on my data sheet. It just some frequency,measurement rate etc. This really helped. I had done it in the past, but since I hadn't commented, I sort of lost track of what was going on there.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by