I'd suggest not modifying findpeaks but to postprocess the results instead--a sample from one of the examples of the basic process I'd undertake:
load mtlb
select = mtlb(1001:1200);
x=1:length(select);
[pks,locs,wdths]=findpeaks(select,x,'MinPeakHeight',2);
% The "engine" to postprocess...
fnInterpL=@(p,l,w) interp1(select(l-fix(w):l),l-fix(w):l,0.8*p);
fnInterpH=@(p,l,w) interp1(select(l:l+fix(w)),l:l+fix(w),0.8*p);
This can be used as:
>> [arrayfun(fnInterpL,pks,locs.',wdths.') arrayfun(fnInterpH,pks,locs.',wdths.')]
ans =
51.3944 53.5555
82.5567 84.8145
145.4656 146.3182
>>
NB: the transpose on the locations/widths vectors; for some reason findpeaks doesn't return all three in same orientation as arrayfun needs.
One could generalize the above a little more by passing in the limit percent as well. Also note the above has the anonymous functions with the builtin signal; probably in a general case would be best to just go ahead and do an m-file where can pass it as well...
ADDENDUM
The above are the boundaries; the width is the difference of course:
>> w80=[arrayfun(fnInterpH,pks,locs.',wdths.')-arrayfun(fnInterpL,pks,locs.',wdths.') ]
w80 =
2.1611
2.2578
0.8526
>>
Best Answer