How to get maxima that are not on a current datapoint?
이전 댓글 표시
Hi all,
I am trying to find the position of major infliction points in a signal. I know there are 2 main infliction points in the signal within the range I am looking at. I am writing a function that pulls these out, which in itself finds them (see below). However, these points are always located on one of the X-values in the dataset. I would like to find them on the actual position if one where to have a continuous line through the data.
I tried using the interpo1 function, on the signals using method pchip, creating 10 times as many points. But when I run that data through the routine, still the calculated maxima are located on the original datapoint location.
What could I be doing wrong?
function [peak] = JF_findpeaks(signatures, offset, startband, endband)
% how many spectra
numspectra = size(signatures(:,1));
% calculate the second derivative of the signatures
% Set window 5, fit second order spline, return second order derivatives
secondderivatives = JF_savitzky_derivative(signatures, 2, 5, 2);
% Subset to the range where we know the peaks are
data = secondderivatives(:,startband-offset:endband-offset);
% create the X-values
waves = startband:endband;
% now find the position of the two peaks in each signature that occurs in the data
for n=1:numspectra
[pksw,locsw] = findpeaks(data(n,:), waves, 'MinPeakProminence',0.00001);
end
end
댓글 수: 1
Image Analyst
2018년 1월 23일
Please attach your data and a screenshot of it plotted. Make it easier for us to help you. I have a hard time working blind.
채택된 답변
추가 답변 (1개)
Walter Roberson
2018년 1월 23일
0 개 추천
The interpolation methods available from interp1(), and also spline(), always go exactly through all points specified. To get a line "through" the point without specifying the point itself, you need to remove the data for the point itself from the interpolation data.
Now if you just delete that one point of data and then ask to interpolate there, then the value will usually be lower than the known data: you have defined the point as being a peak, so the adjacent values are less, so the interpolation will usually be less. An exception could be if you used a spline interpolant, in which case the interpolated arc might happen to go high. But realistically it probably will not go higher -- not unless you have closely-spaced steep data. (The opposite argument applies for the minima: the interpolated points are going to tend to be less than the point.)
Another interpolation method would be to take a portion of the data before and after the inflection and to do a polynomial fit of even order, and use the polynomial to predict the point.
댓글 수: 1
John D'Errico
2018년 1월 23일
I'd argue the problem is not the use of an interpolant, but specifically pchip in this case. pchip is not designed to allow an extreme value that lies between data points. And that is exactly the failure mode that was reported.
카테고리
도움말 센터 및 File Exchange에서 Interpolation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



