% best_gr uses Moore's method for an implicit Fourier Transform. % However, it varies the value of D, the length-scale cut-off in search of the % best possible fit. % To use it, you just have to pass it the data set, and the range in which you think D_Best should fall. function [D, g] = best_gr(data_now, d_min, d_max) global data_now fminbnd('err',d_min,d_max) ; % Evaluates the quality of fit for a particular value of D cut_off function [e] = err(x) global data_now n_min = x * min(data_now(:,1))/ pi ; n_max = x * max(data_now(:,1))/ pi ; [P,e] = sine_fit1(data_now, x, n_min, n_max); end