Find local min point in plot

2 次查看(过去 30 天)
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.

采纳的回答

Cris LaPierre
Cris LaPierre 2022-1-13
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 个)

Voss
Voss 2022-1-13
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 个评论
Anton Vernytsky
Anton Vernytsky 2022-1-14
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 2022-1-14
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by