Dear All,
I have a list as following (for example)
data = {10,8,7,6,5,3,4,5,2,3,2,1,0}
The first local minima is 3.
How can I find this value in Mathematica ?
Thank so much for your help.
Dear All,
I have a list as following (for example)
data = {10,8,7,6,5,3,4,5,2,3,2,1,0}
The first local minima is 3.
How can I find this value in Mathematica ?
Thank so much for your help.
Would this work?
-FindPeaks[-data, 0, 0, -Infinity][[1, 2]]
Cheers,
Marco
Dear Marco,
That’s great.
How can I find the position of this value at the list?
Regards,
Try:
Position[data, 3]
(* {{6}, {10}} *)
Regards,
Mariusz
Hi,
don’t use the “2•. You will also need to multiply the x-value by -1.
Cheers,
Marco
Dear Marco, Mariusz
Thanks again.
I used your solution for my real data. Unfortunately the result shows { }.
Please see the attached file.
Regards,
You need write a pattern using Condition to force searching based on numerical equality:
See here (Position->Possible Issues) for more information.
Regards, Mariusz
I agree that the Position function is a viable option, but keep in mind that FindPeaks gives the x-position of the maxima by default. so something like:
sol = {1, -1}*FindPeaks[-m, 0, 0, -Infinity][[1]]
would give you x and y position of the first minimum. If you use
sol = {1, -1}*# & /@ FindPeaks[-m, 0, 0, -Infinity]
you get the same for all minima. Using Mariusz’ notation:
ListPlot[CorrelationFunction[data, {100}],
TicksStyle -> {{FontSize -> 16, Orange}, {FontSize -> 22, Green}},
PlotRange -> All, AxesLabel -> {Style[x, Large], Style[y, Large]},
Epilog -> {PointSize[0.01], Red, Point /@ sol}]
gives:
Cheers,
Marco
What about an “old fashioned” way without sophisticated “modern” functions?
data = {10, 8, 7, 6, 5, 3, 4, 5, 2, 3, 2, 1, 0};
min = data[[1]];
Catch[
Do[
If[data[[i]] < min, min = data[[i]], Throw[{i - 1, min}]],
{i, 2, Length[data]}]]
{6, 3}