Water retaining property of soil is characterized usually by van-Genuchten model in soil physics.
In this function, I use 'nlinfit' to estimate alpha and n of this model, given some synthetic data (water potential and water content along with residual and saturated water content) . The code is generously commented for easy understanding. First a known soil parameter model is plotted and then synthetic experimental data is generated by erroring and downsampling the model and then we estimate the alpha and n.
Sathyanarayan Rao (2020). Estimating parameters for van-Genuchten soil water retention curve model (https://www.mathworks.com/matlabcentral/fileexchange/67075-estimating-parameters-for-van-genuchten-soil-water-retention-curve-model), MATLAB Central File Exchange. Retrieved .