How to find the first edge (not minimum value) after the peak?

4 vues (au cours des 30 derniers jours)
Vanessa Phung
Vanessa Phung le 26 Juil 2017
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.

Réponse acceptée

Star Strider
Star Strider le 26 Juil 2017
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

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by