% e uses Moore's method for an implicit Fourier Transform. % It takes whatever value of D you care to give it, figures out what harmonics % of n it is allowed to fit and then goes off and does the fit. It returns % the size of the error, which is ultimately what we would like to minimize. % You need to pass it the data and the value of D you want. function [e,Rg,Std_Rg,r,g,delta_g] = err(data, D) n_min = ceil(D * min(data(:,1))/ pi * 0.5) ; n_max = floor(D * max(data(:,1))/ pi) ; [e,Rg,Std_Rg,r,g,delta_g] = sine_fit1(data, D, n_min, n_max);