I have an array (Tw) of this size: 2160 x 1080 x 12
Tw=array(-10:10, c(2160,1080,12))
I also have a temperature array (Ta)
Ta=array(-40:40, c(2160,1080,12))
I want to apply a slightly different function to Ta, depending on whether Tw>=0 or Tw <0.
t.es <- function(T) 6.107 * exp(17.38 * T/(239. + T)) # Tw >= 0
Or
t.es <- function(T) 6.107 * exp(22.44 * T/(272.4 + T)) # Tw <= 0
I tried using an if statement, but it doesn't appear to be working...it seems to just be applying one of the functions:
if(Tw>=0){
t.es <- function(T) 6.107 * exp(17.38 * T/(239. + T)) # Tw >= 0
es <- t.es(Ta)
}else{
t.es <- function(T) 6.107 * exp(22.44 * T/(272.4 + T)) # Tw <= 0
es<- t.es(Ta)
}
How can I do this?
Aucun commentaire:
Enregistrer un commentaire