I am new to Octave so please bear with me..
I have a dataset with x and y values that I plot as a line. Then, I want to annotate selected minima by choosing a range and finding within this range the local minimum. How do I set a range within the x values of my dataset to look into? I figured out a way to find the total minimum or the local minima (by setting a y threshold) but beyond that I am lost.
How do I mark for example the peak at 1450 without marking the peak at 2850? (note that the x axis is inverted)
Thank you!
To find a minimum with a peak height above 0.11
iny=1-y; %invert the data
[pks dm]=findpeaks(invy,"MinPeakHeight",0.11); %look for a local maximum
hold on;
plot(t(dm),y(dm),"xm");
hold off
example of my data and the output when looking for the local minimum with a peak height of 0.11
PS. If someone knows a smart way for me to link my data (2000+ lines), I am happy to do so.
If you want to mark only peaks close to 1450, you could for example use a small range to filter the found peaks. t(dm)
is the position, then sm = (t(dm) > 1400) & (t(dm) < 1500)
selects elements in t(dm)
that are within those limits. The corresponding y values are y(dm)(sm)
.
sm = (t(dm) > 1400) & (t(dm) < 1500);
plot(t(dm)(sm), y(dm)(sm), "xm");