% Demonstrate the Moore_PCF load Compact.dat; % Compact(:,1) = q; Compact(:,2) = I for compact object. load NonCompact.dat; % "" for noncompact object. % Plot the raw data figure(1); clf; plot(Compact(:,1),2100*Compact(:,2),'b'); hold on plot(NonCompact(:,1), 325*NonCompact(:,2),'g'); legend('Compact','NonCompact'); temp =axis; % Mark the valid q-range q_range = [ 0.02 0.2]; plot([ q_range(1) q_range(1)], [temp(3),temp(4)],'r'); plot([ q_range(2) q_range(2)], [temp(3),temp(4)],'r'); xlabel('q (A^{-1}');ylabel('I (Pollacks)'); title('Region of Interest in I versus Q'); % Show what happens when we pick an arbitrary cut-off length D = 200; % Assume PCF goes to zero at D = 200 [rc, pc, ec] = Moore_PCF(Compact, q_range, D); [rnc, pnc, enc] = Moore_PCF(NonCompact, q_range,D); figure(2); clf; plot(rc,pc,'b'); hold on plot(rnc,pnc,'g'); xlabel('r - Angstroms'); ylabel('p(r) - A^{-1}'); title('Pair Correlation Functions : D = 200 Angstroms'); legend('Compact','NonCompact'); % Now utilize error function to optimize length-scale, D D = [130:230]; for j=1:length(D) [rc, pc, temp] = Moore_PCF(Compact, q_range, D(j)); ec(j) = temp; [rnc, pnc, temp] = Moore_PCF(NonCompact, q_range,D(j)); enc(j) = temp; end figure(3); clf; plot(D, ec/max(ec),'b'); hold on plot(D,enc/max(enc),'g'); xlabel('D (Angstroms)'); ylabel('Root Mean Square Fit Error - Normalized'); title('Fitting D'); % Compute the best fit of each. [ecb idx] = min(ec); Dcb = D(idx); [rc, pc, temp] = Moore_PCF(Compact, q_range, Dcb); [encb idx] = min(enc); Dncb = D(idx); [rnc, pnc,temp]= Moore_PCF(NonCompact, q_range,Dncb); figure(4);clf; plot(rc,pc,'b'); hold on; plot(rnc,pnc,'g'); hold on; xlabel('r - Angstroms'); ylabel('p(r) - A^{-1}'); title('Pair Correlation Functions'); legend('Compact','NonCompact');