% Gyration.m calculates the radius of gyration of a small-angle % x-ray scattering curve using the Guinier method. % The input should be a two column matrix of q's and scattering strengths. % The data is plotted to allow the user to pick which range of q-values % should be fitted. Clearly the very low Q-data is meaningless because of the % beam-stop, while the very high Q-data will not fit the Guinier approximation % well. % The variance of the data is assumed to go as 1/q, which is correct for % independent errors at each scattering angle. % The fitting function is I(q) = I(0)*exp(-q^2 Rg^2/3) % This is the guinier approximation % The curve-fit is performed by wlin.m. function [Rg, std_Rg, Io , std_Io] = gyration_l(data) % Find the beginning and the end of the region for a Guiner fit! noise_floor = 0.0005; maximum_Y = max(data(:,2)); for i=1:size(data,1) if (data(i,2)>noise_floor*maximum_Y) Y(i) = log(data(i,2)); else Y(i) = log(noise_floor*maximum_Y) ; end X(i) = data(i,1)^2; end plot(X,Y); disp('You can now play with the graph until you get bored.'); disp('The graph data is in X and Y.'); disp('You probably just want to adjust the range a bit.'); disp('When you are happy, type "return".'); keyboard ; hold on; min_q = input('What is the lowest value of Q^2 to start fit at?'); max_q = input('What is the maximum value of Q^2 to terminate fit at?'); min_i = 1; while(X(min_i)