Effacer les filtres
Effacer les filtres

Find local min point in plot

2 vues (au cours des 30 derniers jours)
Anton Vernytsky
Anton Vernytsky le 13 Jan 2022
Commenté : Voss le 14 Jan 2022
Hello,
I am trying to find the local min on my plot but i want it to find only the minimun of the local min point.
this is my code:
clear all;
clc;
Wavelength = xlsread('Calcite.xlsx','A6:A2156');
reflection = xlsread('Calcite.xlsx','B6:B2156');
lmin=islocalmin(reflection);
figure;
plot(Wavelength,reflection,Wavelength(lmin),reflection(lmin),'ro')
title('(111b Sample) Relative Reflectance--Wavelength')
xlabel('Wavelength[nm]')
ylabel('Relative Reflectance')
grid on
grid minor
as you can see i get all the min points but i want to get only the minimum of the local min.
Thank you for your help.

Réponse acceptée

Cris LaPierre
Cris LaPierre le 13 Jan 2022
I suggest trying out the 'Find local extrema' live task. This will allow you to interactively set criterial for finding maxima and minima in your signal. Once you have the correct parameters, you can convert the task to code if you want, or keep the task in your live script.
  1 commentaire
Anton Vernytsky
Anton Vernytsky le 13 Jan 2022
Thank you ! it helped me.

Connectez-vous pour commenter.

Plus de réponses (1)

Voss
Voss le 13 Jan 2022
clear all;
clc;
Wavelength = xlsread('Calcite.xlsx','A6:A2156');
reflection = xlsread('Calcite.xlsx','B6:B2156');
% lmin=islocalmin(reflection);
lmin = find(islocalmin(reflection));
[~,idx] = min(reflection(lmin));
idx = lmin(idx);
figure;
% plot(Wavelength,reflection,Wavelength(lmin),reflection(lmin),'ro')
plot(Wavelength,reflection,Wavelength(idx),reflection(idx),'ro');
title('(111b Sample) Relative Reflectance--Wavelength')
xlabel('Wavelength[nm]')
ylabel('Relative Reflectance')
grid on
grid minor
  4 commentaires
Anton Vernytsky
Anton Vernytsky le 14 Jan 2022
It only showed me the lowest point,what i did was the first solution,this is the code and plot:
clear all;
clc;
Wavelength = xlsread('Calcite.xlsx','A6:A2156');
reflection = xlsread('Calcite.xlsx','B6:B2156');
lmin = islocalmin(reflection,"MinSeparation",300);
figure;
plot(Wavelength,reflection,Wavelength(lmin),reflection(lmin),'ro')
title('(111b Sample) Relative Reflectance--Wavelength')
xlabel('Wavelength[nm]')
ylabel('Relative Reflectance')
grid on
grid minor
Voss
Voss le 14 Jan 2022
I interpreted "find only the minimun of the local min point" to mean "find the lowest local minimum". So yeah, if you want to ignore certain local minima because they are close to another local minimum or whatever, you can't use my code for that.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by