Get absolute peak location in a vector in MATLAB

前端 未结 2 661
醉话见心
醉话见心 2021-01-24 00:45

Suppose I have the A matrix like this:

A =    [0,0,0,0,0,0,106,10,14,20,20,23,27,26,28,28,28,23,28,28,21,18,106,14,12,
17,16,15,22,19,20,18,21,23,23,18,17,15,106         


        
相关标签:
2条回答
  • 2021-01-24 01:07

    This does not give you all the peaks, but it gives you the maximum value in the set:

    max_locations = find(A==max(A))
    

    If you want to find the peaks, use the findpeaks function:

    [peakVal,peakLoc]= findpeaks(A);
    
    0 讨论(0)
  • 2021-01-24 01:34

    If you want maximum 5 or 10 peaks, use the following

    [peakVal,peakLoc]= findpeaks(A,'sort','descend');
    
    0 讨论(0)
提交回复
热议问题