1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| function [N,M] = reader8()
a = fopen('datas_8sec.txt')
b = textscan(a,'%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n','delimiter',',');
%x= 0.29:(78.31-0.29)/(511):78.31; Energy (Kev)
x= 0.29*0.0525/1.24: (78.31-0.29)*0.0525/1.24/(511):78.31*0.0525/1.24;% momentum transfert (nm-1), with teta=6 degres
N=size(x);
M=size(b);
p=1./x; % or 2*pi./x;
%r=size(p)
nsample=311;
tic
for k=1:nsample; % k = the sample's area
Fk=b(k);
Fk=Fk{:};
Fk=Fk'; %transposition
%nk=size(ak)
figure(k) % open a figure for sample's plots
subplot(2,1,1) % first plot area
%plot(x,Fk);grid; % the real fit of datas
%hold on
m=10; % start of signal's filter with the Rectangular function Method, width 2*m+1
t=ones(2*m+1,1)./(2*m+1);
f=filter(t,1,Fk);
f(1:m-1)=Fk(1:m-1);
f(m:N-m)=Fk(m+m:N); % end of signal's filter
plot(x,f,'g');grid; % the smooth datas fit
str=sprintf('counts(x): size 1mm*2mm; exposure time: 8s, area%d',k); % creation of a variable area_k for title indexation
title(str);
Xlabel('momentum transfert (nm-1)');
Ylabel('counts');
Fk=abs(fftshift(f)); % |center FFT|
subplot(2,1,2) % second plot area
plot(p,Fk,'r');grid; % |center FFT| fit
str2=sprintf('FFT(number of counts): size 1mm*2mm; exposure time: 8s, area%d',k);% creation of a variable area_k for title indexation
title(str2);
Xlabel('p (nm)');
Ylabel('FT(counts)');
axis([0.25 0.55 0 14]); % keep the interesting signal of FFT, cut the lowest x values => cut the highest p values
saveas(gcf,['figure',num2str(k)],'m'); % save figures in the current folder
end;
toc |
Partager