0

Hi I am trying to interpolate temperature height from ground.

Knowing the following information tempA, heightA, tempB, heightB, I need to find where targetedTemperature occurs.

 public static double TemperatureHeight(
            double heightA, double tempA,
            double heightB, double tempB,
            int targetTemperature)
        {
            //heightA = 4322.76; //height in Meters from ground
            //heightB = 4989.064; //height in Meters from gound
            //tempA = -9.9; // Temperature in celcius at heightA
            //tempB = 13.6; // Temperature in celcius at height B
            //targetTemperature = -10; //At what height from ground, this temperature exists?


            //This is temporary solution, to pick closest height. Ideally I would like to know at what height (in meters) does targetTemperature exists.
            if (targetTemperature - tempA > targetTemperature - tempB)
                return heightB;
            return heightA;
        }

I found similar question here https://stackoverflow.com/a/25882161/942855 but not exactly what I need.

HaBo
  • 13,999
  • 36
  • 114
  • 206
  • What's the problem? Have you tried linear interpolation? What part of this do you need help with? What went wrong with what you tried? What do you expect as results? – Wyck Apr 06 '20 at 17:07
  • Thanks this looks like working for what I need https://stackoverflow.com/a/12838328/942855. Will validate it further and comment if there is any discrepancy – HaBo Apr 06 '20 at 17:32

0 Answers0