# Find local min point in plot

3 views (last 30 days)
Anton Vernytsky on 13 Jan 2022
Commented: _ on 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;
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.

Cris LaPierre on 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.
Anton Vernytsky on 13 Jan 2022
Thank you ! it helped me.

_ on 13 Jan 2022
clear all;
clc;
% 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
_ on 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.