How to identify min and max within a specific range of a matrix?

조회 수: 14 (최근 30일)
Georg Gamauf
Georg Gamauf 2016년 7월 23일
댓글: Star Strider 2016년 7월 23일
Hi everyone!
I have a set of data (200000x1 matrix), shown in the first attachment:
Now I want to focus on specific range around the first (highest) peak. I was able to plot only the interesting region and to mark the peaks by using:
plot(timeMsT,chA,'b');
...
plot(locs1,pks1,'rs','MarkerFaceColor','r');
hold on;
plot(locs2,-pks2,'rs','MarkerFaceColor','r');
...
See second attachment:
Now i want to identify (=getting x- and y-value) the three peaks that are marked, as well as a fourth one (the first positive peak). I was able to identify the highest positive and the lowest negative one, using:
MAXIMUM:
[pks1,locs1] = findpeaks(chA,timeMsT,'MinPeakHeight',10);
Amplitude1 = max(pks1);
MINIMUM:
chAinverted = -chA;
[pks2,locs2] = findpeaks(chAinverted,timeMsT,'MinPeakHeight',20);
Amplitude2 = max(pks2);
I don't know how to identify x- and y-value of the other peak(s). Is it possible to create a new matrix element out of "chA" (200000x1), which contains only the specific range of data?
I tried:
chAnew = chA(left:right)
as well as
chAnew = chA([left right])
, but it didn't work.
Kind regards
Georg
  댓글 수: 1
Star Strider
Star Strider 2016년 7월 23일
Georg Gamauf Commented (14.00 UTC)
Guys! I just found the solution. I simply had to set the range to
xl = time1-50;
xr = time2+50;
chAnew = chA(xl:xr);
timenew = timeMsT(xl:xr);
because time1 and time2 were already set as indices of the highest and the lowest peak!

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

답변 (1개)

Image Analyst
Image Analyst 2016년 7월 23일
chA(left:right) should work to crop out a section, while the second line of code you tried won't. Perhaps you didn't calculate left and right properly. You'd also need to crop out the timeMsT values too, unless you just wanted to work with indexes from the new, shorter array.
  댓글 수: 3
Georg Gamauf
Georg Gamauf 2016년 7월 23일
Guys! I just found the solution. I simply had to set the range to
xl = time1-50;
xr = time2+50;
chAnew = chA(xl:xr);
timenew = timeMsT(xl:xr);
because time1 and time2 were already set as indices of the highest and the lowest peak!

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

카테고리

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