How to find the first edge (not minimum value) after the peak?
3 次查看(过去 30 天)
显示 更早的评论
The subplot 1 shows a line profile across a density column. I want to find the radius of this column by getting the coordinate of peak(max) and the first edges. The problem is that the edge is not at minimum value, therefore I can't use min().
The subplot 2 is obtained from findpeaks().
figure; imagesc(FT_phase_shift), colorbar;title('Phase shift'); aline=FT_phase_shift(1:600,700); amax=max(aline);amin=min(aline) pmax =find(aline==amax(:,1));pmin=find(aline==amin(:,1));x_max = aline(pmax);
% find peaks and location [pks, locs]= findpeaks(aline); figure;subplot (211); plot(aline); subplot(212); plot(locs, pks);
Please comment.Thank you.
0 个评论
采纳的回答
Star Strider
2017-7-26
I would use findpeaks on the negative of your signal:
[negpks, neglocs]= findpeaks( -aline );
Then take the first ‘neglocs’ value less than the maximum peak ‘locs’ value, and the first ‘neglocs’ value greater than the the maximum peak ‘locs’ value. Use the corresponding ‘negpks’ values (as ‘-negpks’) to find the values you want.
Example —
x = linspace(0, 10*pi); % Create Data
aline = abs(sin(x-5*pi)./(x-5*pi))*7; % Create Data
[pks, locs]= findpeaks(aline, 'MinPeakHeight',5);
[negpks, neglocs]= findpeaks( -aline );
minidx = find(neglocs < locs, 1, 'last');
maxidx = find(neglocs > locs, 1, 'first');
minloc = neglocs(minidx);
maxloc = neglocs(maxidx);
figure(1)
plot(x,aline,'-b', x(locs),pks,'^r')
hold on
plot(x([minloc maxloc]), aline([minloc maxloc]), 'vr')
hold off
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!