I have a 200 cycles of matrix data where a value changes from -1, reaches a maximum of 7 and drops to 1. Then again it drops to -7 and reaches to -1. How do I capture these two individual positive and negative peaks repeating over 200 cycles.

댓글 수: 1

Walter Roberson
Walter Roberson 2017년 12월 1일
Perhaps find() the 0 crossings, diff() of those give the lengths of each stretch, which gives you the information you need to mat2cell() ?

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

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2017년 12월 1일

0 개 추천

[v0,i0] = findpeaks(-x(:));
[v,ii] = findpeaks(x(:));
a = zeros(numel(x),1);
a([i0,ii]) = 1;
[v1,i1] = ismembertol(x,[-1 ; 1],.2,'DataScale',1);
Groups = cumsum(v1 & a);
out = accumarray(Groups,x(:),[],@(x){x});

댓글 수: 1

AT
AT 2017년 12월 1일
Thanks for your answer. Could you please explain the code?

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

카테고리

질문:

AT
2017년 12월 1일

댓글:

AT
2017년 12월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by