Hello,
I would like to save the the x and y values of the marked point on the plot.
Can someone explain me please how to write a code or what functions can i use.
Thank you !

 Respuesta aceptada

Scott MacKenzie
Scott MacKenzie el 12 de Mzo. de 2022
Editada: Scott MacKenzie el 12 de Mzo. de 2022
OK, this seems to to work. The x-y coordinates of the marked points are output to the command window (along with the figure number). For brevity, I'm just showing the result for the 1st data set.
format shortg
xlsdata=xlsread('temp.xlsx'); % this is the data in your ForDataMining.xlsx file
Wavelength=xlsdata(2:2152);
for i=1:1 % first data set only, adjust as desired
reflection = xlsdata(2:2152,i+1);
lmin = islocalmin(reflection,"MinProminence",0.01,"MinSeparation",100);
% get x-y coordinates of minima
x = Wavelength(lmin)';
y = reflection(lmin);
figNumber = repmat(i, numel(x), 1);
[figNumber x y] % output in command window (include figure number)
figure(i) % put figure statement here
plot(Wavelength,reflection,Wavelength(lmin),reflection(lmin),'ro')
title('Relative Reflectance-Wavelength')
xlabel('Wavelength[nm]')
ylabel('Relative Reflectance')
grid on
grid minor
end
ans = 7×3
1.0e+00 * 1 447 0.83857 1 1435 0.90312 1 1754 0.97845 1 1928 0.75198 1 2157 0.94879 1 2339 0.55042 1 2482 0.9139

2 comentarios

Anton Vernytsky
Anton Vernytsky el 12 de Mzo. de 2022
Thank you for your help.
Scott MacKenzie
Scott MacKenzie el 12 de Mzo. de 2022
@Anton Vernytsky you're welcome. Glad to help.

Iniciar sesión para comentar.

Más respuestas (1)

Scott MacKenzie
Scott MacKenzie el 12 de Mzo. de 2022
Editada: Scott MacKenzie el 12 de Mzo. de 2022

0 votos

Since you haven't provided any data or code, this is a rough answer only:
[pks, locn] = findpeaks(-y, 'MinPeakProminence', 0.1);
Using -y will give you the valleys, which is what you are after. You'll need to play with the peak prominence value to the get the valleys you want and exclude those you don't want. Then, you need to take the negative of pks to get the actual y values of the valleys. You can use locn to retrieve the corresponding x values.

4 comentarios

Anton Vernytsky
Anton Vernytsky el 12 de Mzo. de 2022
Oh sorry,i wrote a code that finds this red point,what i did till now is to click on that point and right click and save data,i would like to write a code that save this point data auto.
This is my code:
clear all;
clc;
xlsdata=xlsread('ForDataMining.xlsx');
Wavelength=xlsdata(2:2152);
for i=1:10
reflection = xlsdata(2:2152,i+1);
lmin = islocalmin(reflection,"MinProminence",0.01,"MinSeparation",100);
plot(Wavelength,reflection,Wavelength(lmin),reflection(lmin),'ro')
title('Relative Reflectance-Wavelength')
xlabel('Wavelength[nm]')
ylabel('Relative Reflectance')
grid on
grid minor
figure(i)
end
Scott MacKenzie
Scott MacKenzie el 12 de Mzo. de 2022
Could you also post the data file? Just click on the paperclick and select the file.
Anton Vernytsky
Anton Vernytsky el 12 de Mzo. de 2022
Scott MacKenzie
Scott MacKenzie el 12 de Mzo. de 2022
OK,thanks. I posted a solution as a separate answer.

Iniciar sesión para comentar.

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 12 de Mzo. de 2022

Editada:

el 12 de Mzo. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by