我已经有了一个相位屏幕( 2-D NxN矩阵和大小比例的LxL,例如:N= 256,L=2米)。
我想在Matlab程序中找到由D(δ(R))= 定义的相位结构函数- D(r) (<.>是系综求平均值,r是仪表中相位屏上的位置,x是相位屏点处的相位值,δ(R)是可变的,不是固定的)。你对我的目的有什么建议吗?
P/S:我试图通过自相关(定义为B(r))来计算D(r),但这种计算仍然保留了一些近似值。因此,我想精确地计算D(r)的结果。你能请see this image to better understand the definition of D(r) and B(r)吗。下面是我计算B(r)的函数代码。
% Code copied from "Numerical Simulation of Optical Wave Propagation with Examples in Matlab",
% by Jason D. Schmidt, SPIE Press, SPIE Vol. No.: PM199
% listing 3.7, page 48.
% (Schmidt defines the ft2 and ift2 functions used in this code elswhere.)
function D = str_fcn2_ft(ph, mask, delta)
% function D = str_fcn2_ft(ph, mask, delta)
N = size(ph, 1);
ph = ph .* mask;
P = ft2(ph, delta);
S = ft2(ph.^2, delta);
W = ft2(mask, delta);
delta_f = 1/(N*delta);
w2 = ift2(W.*conj(W), delta_f);
D = 2 * ft2(real(S.*conj(W)) - abs(P).^2, delta) ./ w2 .*mask;`
%fire run
N = 256; %number of samples
L = 16; %grid size [m]
delta = L/N; %sample spacing [m]
F = 1/L; %frequency-domain grid spacing[1/m]
x = [-N/2 : N/2-1]*delta;
[x y] = meshgrid(x);
w = 2; %width of rectangle
%A = rect(x/2).*rect(y/w);
A = lambdaWrapped;
%A = phz;
mask = ones(N);
%perform digital structure function
C = str_fcn2_ft(A, mask, delta);
C = real(C);发布于 2018-05-30 05:44:12
直接计算此函数D(r)的一种方法是通过随机采样:在屏幕上选取两个随机点,确定它们的距离和相位差的平方,并更新累加器:
phi = rand(256,256)*(2*pi); % the data, phase
N = size(phi,1); % number of samples
L = 16; % grid size [m]
delta = L/N; % sample spacing [m]
D = zeros(1,sqrt(2)*N); % output function
count = D; % for computing mean
for n = 1:1e6 % find a good amount of points here, the more points the better the estimate
coords = randi(N,2,2);
r = round(norm(coords(1,:) - coords(2,:)));
if r<1
continue % skip if the two coordinates are the same
end
d = phi(coords(1,1),coords(1,2)) - phi(coords(2,1),coords(2,2));
d = mod(abs(d),pi); % you might not need this, depending on how A is constructed
D(r) = D(r) + d.^2;
count(r) = count(r) + 1;
end
I = count > 0;
D(I) = D(I) ./ count(I); % do not divide by 0, some bins might not have any samples
I = count < 100;
D(I) = 0; % ignore poor estimates
r = (1:length(D)) * delta;
plot(r,D)如果您需要更高的精度,请考虑插值。将随机坐标计算为浮点值,并对相位进行插值以获得采样之间的值。然后,D需要更长,索引为round(r*10)或类似的内容。你将需要更多的随机样本来填充更大的累加器。
https://stackoverflow.com/questions/50494895
复制相似问题