Public feed #893248

code from Demarcus

public text v1 · immutable
Raw Edit
·published 2008-02-06 00:07 UTC
rendered paste body
function maximum = r_peaks(data)
regions = find(data > (.65 * max(data)));
ends = [find(diff(regions) > 1);  length(regions)];

% the regions
region1 = regions(1:1:ends(1));
region2 = regions(ends(1)+1:1:ends(2));
region3 = regions(ends(2)+1:1:ends(3));

% the maxes
[max1, ind1] = max(region1);
[max2, ind2] = max(region2);
[max3, ind3] = max(region3);

maxI1 = region1(1) + (ind1 - 1);
maxI2 = region2(1) + (ind2 - 1);
maxI3 = region3(1) + (ind3 - 1);

maximum = [maxI1, maxI2, maxI3];