There is Pmax matrix as function of two parameters T and G in X and Y axis respectively with different values.

I wants a point in the matrix surface at different T (target T) and G (target G) which is not in the matrix directly. How do I identify 4 points near target point in the G-T power matrix. That means identify two T values adjacent to target T and two G values adjacent to target G.

Like,

IF Pmax matrix (Row T, 1) < target T > Pmax matrix (Row T +1, 1)

THEN Tstartpoint = Row T

Tendpoint = Row T+1

IF Pmax matrix (Col G, 1) < target G > Pmax matrix (Col G +1, 1)

THEN Gstartpoint = Col G

Gendpoint = Col G +1

Can you please help me how to get this above code in Excel or in DELPHI