StormMedic85
Programmer
I'd like to write a subroutine that performs an average of a variable over a specific layer of the atmosphere. In order to do the averaging, I need to pass in the values I wish to average (that part's easy), the current altitude (also easy), but then I also need the previous altitude since I am doing a backwards difference average.
In other words, I need to determine the thickness of the layer (current level - previous level). I am uncertain of an efficient way to pass in the previous altitude of a data set.
One way I was thinking, though inefficient, would be to return both the average and current altitude in the subroutine, then push the current altitude into an array and pass it back into the subroutine for the other values. Does anybody have any other suggestions? I'm thinking that perhaps I could do something with a for loop...like $alt[$i]-$alt[$i-1], but I'm not sure.
Thanks!
In other words, I need to determine the thickness of the layer (current level - previous level). I am uncertain of an efficient way to pass in the previous altitude of a data set.
One way I was thinking, though inefficient, would be to return both the average and current altitude in the subroutine, then push the current altitude into an array and pass it back into the subroutine for the other values. Does anybody have any other suggestions? I'm thinking that perhaps I could do something with a for loop...like $alt[$i]-$alt[$i-1], but I'm not sure.
Thanks!