2018/08/09

Matlab: Find local maxima 求局部極大值

To find the local maximum values in Matlab, use findpeaks():

>> a = [7 -2 -5 8 -6 -3 4 9 6 3 -2 5 8 11 7 3 -5];
[peaks, items] = findpeaks(a);
>> peaks

peaks =

     8     9    11

>> items

items =

     4     8    14

>> 

To find N large elements of a vector in Matlab in descending order, use maxK():

K>> [peaks, items] = maxk(a,5);
K>> peaks

peaks =

    11     9     8     8     7

K>> items

items =

    14     8     4    13     1

K>> 

Reference:

findpeaks - Find local maxima (MathWorks)

沒有留言:

張貼留言