1

I'm trying to find the index of the maximum value of rgdBins1 and use it as an index to rgMHz to find Fmax. Here's a snippet from my code.

 Dim Fmax As Double Dim indexMax As Integer For i As Integer = 0 To nBins Dim sqrt As Double = Math.Sqrt(2) rgdBins1(i) = 20.0 * Math.Log10(rgdBins1(i) / sqrt) 'Converting to dBV rgMHz(i) = MHzFirst + MHzStep * (i) If rgdBins1(i + 1) > rgdBins1(i) Then Debug.Print("Not yet Max") Else indexMax = i End If Next Fmax = rgMHz(indexMax) Console.Write(Fmax) 
2
  • Add dim rgdMax as Double = 0.0 and change the condition in if rgdBins1(i) > rgdMax then rgdMax = rgdBins1(i) indexMax = i end if -- If that is the question. Not sure what the relation between nBins and rgdBins1() is here -- You could also have a class object that associates a rgdBins with rgMHz, then use the Max() extension method on a List of these class objects Commented Sep 29, 2022 at 8:01
  • 1
    You might find How do I get the index of the highest value in an array using LINQ? interesting. Commented Sep 29, 2022 at 17:50

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.