@hosseini: please take a look at the tests included in the bottom of file convert_humidity.m. For example, to convert specific humidity (s) to relative humidity (r) you'd do:
r = convert_humidity (P, T, s, 'specific humidity', 'relative humidity');
where P and T stands for pressure and temperature.
I used this function to convert from specific humidity to relative humidity. A few of my values (about 6%) were above 100% relative humidity. The data I am using is straight from CMIP5, and has not been altered. All the variables are in the correct units. Any idea why I have impossible above 100% values?????? (there are some that are 100.2% and others that are 120%). The rest of the values look normal around 60 - 90 percent.
16 Apr 2011
Included PDF describing formulation; applied more tags.