%% Wigner Function Transformation clc clear ds = 0.005; %sampling rate at every 5mm fs = 1/ds; % sampling frequency L=60; %sets the number of sample points D=0.295; %sets the physical distance range c=3e8; f=3e9; %freq lambda=c/f; k=2*pi/lambda; load('Hy_R1(x1,y1,x2,y2)_36pos_1cm.mat'); % load source CF=R(x1,y1,x2,y2) CF = permute(Hy_R1,[1,3,2,4]); % CF(x1,x2,y1,y2) clear Hy_R1 %% 1. Variable change Part 1 for k=1:L for n=1:L R = CF(:,:,k,n); %R(x1,x2) % variable rotation for each inner matrix % variable change on the correlation matrix R(X2,X1) -> R(x,sx) for X1 = [1:L]; % nx matrix for X2 = [1:L]; % ny matrix x = (X1+X2)/2; % change of variable X1/X2 to x sx = (X1-X2); % change Q(sx+L,2*x-1)=(R(X1,X2)); %Q(sx,x) value end end % averaging in between the values already calculated after variable change for h = 2:2:2*L-2 Q(h,L) = (Q(h-1,L)+Q(h,L-1)+Q(h,L+1)+Q(h+1,L))/4; end for t=1:L-1 for m = 1:L-1 Q(m+t,L-m+t) = (Q(m+t-1,L-m+t)+Q(m+t,L-m+t-1)+Q(m+t,L-m+t+1)+Q(m+t+1,L-m+t))/4; end end % after averaging, arrange the rotated inner matrix into AA(sx,x,x2,y2) AA(:,:,k,n) = Q; % AA(sx,x,y2,y1) end end clear CF clear R clear Q %% 2. Variable change Part 2 R = AA; % AA(sx,x,y1,y2) % variable change on the outer correlation matrix R(X1,X2) -> R(x,s) for y1 = [1:L]; % nx matrix for y2 = [1:L]; % ny matrix y = (y1+y2)/2; % change of variable to y sy = (y1-y2); % change sy=y1-y2 q(:,:,sy+L,2*y-1)=(R(:,:,y1,y2)); %D(s,x) value end end % averaging in between the real value after variable change for h = 2:2:2*L-2 q(:,:,h,L) = (q(:,:,h-1,L)+q(:,:,h,L-1)+q(:,:,h,L+1)+q(:,:,h+1,L))/4; end for t=1:L-1 for m = 1:L-1 q(:,:,m+t,L-m+t) = (q(:,:,m+t-1,L-m+t)+q(:,:,m+t,L-m+t-1)+q(:,:,m+t,L-m+t+1)+q(:,:,m+t+1,L-m+t))/4; end end clear R clear AA %% 3. rearrange Q(sx,x,sy,y) -> Q(sy,sx,y,x) and do FFT2 on sx and sy CFr=permute(q,[3,1,4,2]); %rearrange Q to be CFr(sy,sx,y,x) clear q %% pmax=lambda/2*fs; range = 1.5; % new range -1.5 R(x,s) for X1 = [1:L]; % nx matrix for X2 = [1:L]; % ny matrix x = (X1+X2)/2; % change of variable x to X1/X2 sx = (X1-X2); % change RR(X1,X2)=F(sx+L,2*x-1); %RR(X1,X2) end end CF2(:,:,k,n) = RR; % set CF2(x1,x2,y1,y2) end end %% load('SF1.mat') % scaling factor Hy_CF3 = CF2 .* SF1; %Hy_CF3 = CF2 .* SF1.*(PF_ave(1601)^2); x=linspace(-D/2,D/2,L); % range of x y=linspace(-D/2,D/2,L); % range of y size = 14; figure pcolor(x,y,squeeze(abs(Hy_CF3(30,:,30,:)))'); %Hy_CF3(x1,x2,y1,y2) title('$$CF\,propagated\,to \,10\,cm$$','Interpreter','latex', 'FontSize', size) set(gca,'YDir','normal') colormap('jet'); colorbar shading interp %caxis([0 14e-4]) xlabel('$$x_1 [m]$$','Interpreter','latex', 'FontSize', size); ylabel('$$y_1 [m]$$','Interpreter','latex', 'FontSize', size); set(gca,'fontsize', size)