필터 지우기
필터 지우기

How can I find the value of vector for the local maximum and the nearest local minima (befor and after maximum value)?

조회 수: 2 (최근 30일)
Hi,
I have a vector array (e.g. 2 12 4 6 9 4 2 5 10 19 7 5 3 7 4) and I need to define the part of the vector with local maximum value and the neighbouring minima, located to the left and right of the maximum). In the above example it should be [2 5 10 19 7 5 3].how can I code that in matlab? any help please..
Thanks,

채택된 답변

Image Analyst
Image Analyst 2013년 6월 8일
Why does the 12 at element 2 not qualify as a local max? Do you have the Image Processing Toolbox, try imregionalmax(). If you have the Signal Processing Toolbox, try findpeaks on the signal and the inverted signal.
  댓글 수: 3
Image Analyst
Image Analyst 2013년 6월 8일
편집: Image Analyst 2013년 6월 8일
Try this:
m = [2 12 4 6 9 4 2 5 10 19 7 5 3 7 4]
regMax = imregionalmax(m)
regMin = imregionalmin(m)
% Find the 3rd peak
index3 = find(regMax, 3, 'first')
index3 = index3(end)
% Find out the mins on either side of that.
% Find the min locations
minLocations = find(regMin)-index3
% Find where the first one goes positive (right side)
rightIndex = minLocations(find(minLocations>0, 1, 'first'))+index3
% Get the left side:
leftIndex = minLocations(find(minLocations<=0, 1, 'last'))+index3
% Get the stretch from left min to right min on either side of the 19.
stretch = m(leftIndex:rightIndex)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by