# How to find first two largest peaks with sample location

조회 수: 93(최근 30일)
Muhammad Usman Gul 2020년 2월 6일
댓글: Bhaskar R 2020년 2월 6일
Please let me know, how to find its two highest peaks along with its samples information too.

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

### 채택된 답변

d = rand(100,1); % assumed data
[vals,loc] = maxk(d,2); % first two peaks(mnaximum values) sample values and locations
plot(d); hold on; % plot original samples
plot(loc,vals,'rv', 'MarkerFaceColor', 'r'); % plot peak values
##### 댓글 수: 2표시숨기기 이전 댓글 수: 1
Yeah, I got you. Use findpeaks to get all peak values of the samples
d = rand(100,1); % assumed data
[vals,locs] = findpeaks(d);
[val,loc] = maxk(vals,2); % first two peaks(mnaximum values) sample values and locations
plot(d); hold on; % plot original samples
plot(locs(loc),val,'rv', 'MarkerFaceColor', 'r'); % plot peak values

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

### Community Treasure Hunt

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

Start Hunting!

Translated by