awsome! This is exactly what I need. I am a little confused about one thing...I have an n x 2 matrix in datain that consists of x=precip and y=groundwater level that I would like to do the regression on and get the y-predictions using the lowess regression results. I modified the function to not include the "xdata" and "xy" but I am getting errors about the try-catch syntax on line 298 of the m-file.I have version 7.4.0 (R2007a). The error states that it will continue to run but I dont get results. Am I putting the data in the wrong place? Do I need to put a second data set in? I wanted to take the resulting predicted y values and run the Mann-Kendall test to see if i see a significant trend. what is the purpose of the second dataset of x-values? As you can tell I am new to Matlab and it would be wonderful if I could figure this out! thanks so much!! If i can get this to work for my data this would be AMAZING!