首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >根据定义绘制相位屏幕的相位结构函数

根据定义绘制相位屏幕的相位结构函数
EN

Stack Overflow用户
提问于 2018-05-24 02:14:04
回答 1查看 305关注 0票数 0

我已经有了一个相位屏幕( 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)的函数代码。

代码语言:javascript
复制
% 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);
EN

回答 1

Stack Overflow用户

发布于 2018-05-30 05:44:12

直接计算此函数D(r)的一种方法是通过随机采样:在屏幕上选取两个随机点,确定它们的距离和相位差的平方,并更新累加器:

代码语言:javascript
复制
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)或类似的内容。你将需要更多的随机样本来填充更大的累加器。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50494895

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档