driver_cp_fit.m is a driver program to fit a power function to a particulate attenuation spectra. It calls least_squares_cp.m which is where the function to minimize (y) is defined. If the uncertainties in the attenuation values vary with wavelength, one should add the variance as a weight in the the y-funciton of least_squares.m. If you are afraid that outliers are affecting your slopes, use a robust minimization: rather than minimizing the square difference minimize the absolute values of the differences in y. To calculate the uncertainties in the fit paramters you could use a Monte-Carlo technique: add randomly noise to the data (based on your knowledge of the uncertainties and their statistics) to the spectra and recompute the fit. After you have done so suficiently (~1000 times) compute the statistics of the fit parameters. These are your uncertainties.