Home > matlab code > locate_peaks matlab function

locate_peaks matlab function

function indices = locate_peaks(ip)
%function to find peaks
%a peak is any sample which is greater than its two nearest neighbours
    index = 1;
    num = 2;
    indices = [];
    for k = 1 + num : length(ip) - num
        seg = ip(k-num:k+num);
        [val, max_index] = max(seg);
        if max_index == num + 1
            indices(index) = k;
            index = index + 1;
        end;
    end;
Advertisement
Categories: matlab code
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: