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)
dim rgdMax as Double = 0.0and change the condition inif rgdBins1(i) > rgdMax then rgdMax = rgdBins1(i) indexMax = i end if-- If that is the question. Not sure what the relation betweennBinsandrgdBins1()is here -- You could also have a class object that associates argdBinswithrgMHz, then use theMax()extension method on a List of these class objects