这是我在这里询问的第一个问题,请耐心等待。我对Matlab并不陌生,但之前从未使用过MVNRND函数,而且我的统计知识并不强大。我试图做的总结如下:我试图创建一个函数,生成2个相关的相位屏幕(NxN矩阵),将用于电磁高斯谢尔模型光束传播模拟。光束需要用于X和Y偏振状态的单独的随机相位屏幕。我到目前为止的代码如下。在Matlab中使用MVNRND创建2个高斯相关矩阵
function [phz_x,phz_y]=GSM_phase_screen_2(l_phi_x,l_phi_y,sigma_phi_x, ...
sigma_phi_y,gamma,N,delta)
%GSM_PHASE_SCREEN_2
% This code generates two correlated 2-D NxN Gaussian Schell-Model (GSM)
% phase screens (matrices) of unit variance circular complex Gaussian
% random numbers for the X and Y polarization states provided l_phi_x,
% l_phi_y, sigma_phi_x, sigma_phi_y, and gamma. It utilizes the MVNRND
% Matlab function.
%
% l_phi_x: [m] correlation length in X phase screen
% l_phi_y: [m] correlation length in Y phase screen
% sigma_phi_x: phase variance in X phase screen
% sigma_phi_y: phase variance in Y phase screen
% gamma: correlation coefficient
% N: number of samples per side of grid
% delta: [m] sample grid spacing
%
% phz_x: [rad] 2-D phase screen for X polarization state
% phz_y: [rad] 2-D phase screen for Y polarization state
% ORIGINAL AUTHOR: Santasri Basu
% MODIFIED BY: Matthew Gridley
% Added input arguments needed to generate 2 correlated phase
% screens, updated PSD equations, and replaced RANDN with MVNRND
%
% Setup the Power Spectral Density (PSD)
del_f = 1/(N*delta); % frequency grid spacing [1/m]
fx = (-N/2 : N/2-1) * del_f;
% Frequency grid
[fx,fy] = meshgrid(fx);
% GSM phase PSD
PSD_phi_x = (sigma_phi_x^2) * pi * (l_phi_x^2) * gamma * ...
exp(-((pi * l_phi_x)^2) * (fx.^2 + fy.^2));
PSD_phi_y = (sigma_phi_y^2) * pi * (l_phi_y^2) * gamma * ...
exp(-((pi * l_phi_y)^2) * (fx.^2 + fy.^2));
% Random draws of Fourier series coefficients
% (zero mean Gaussian random numbers)
%
% the 2 lines of code below need changed to generate the correlated random
% draws using MVNRND and GAMMA
cn_x = (randn(N) + 1i*randn(N)) .* sqrt(PSD_phi_x) * del_f;
cn_y = (randn(N) + 1i*randn(N)) .* sqrt(PSD_phi_y) * del_f;
% Synthesize the phase screens
phz_x = real(ift2(cn_x,1));
phz_y = real(ift2(cn_y,1));
end
function [g, x] = ift2(G, df)
% [g, x] = ift2(G, df)
% 2-D inverse Fourier transform that keeps the origin at the center of
% the grid.
%
% G: Complex field in frequency space
% df: Spacing in frequency space [m^-1]
% g: Complex field in coordinate space
% Core function written by Jason Schmidt
% Modified: 17 Apr 2010
% By: Daniel J. Wheeler
%
% x output added functionality by Michael Steinbock 6/8/2014
%
g = ifftshift(ifft2(ifftshift(G))) * (length(G) * df)^2;
%% Calc x:
if nargout == 2
N = size(G, 1);
x = (0 : N-1)/(N*delta_f);
end
在上面的代码,代码的两行与开始的评论下面的“%随机抽取傅立叶级数系数”是,我需要帮助。我以前用你看到的代码做了两个矩阵,但意识到它们不是高斯相关的。从我的学术顾问的建议,我应该使用MVNRND生成这些阶段屏幕。在查看了MVNRND的帮助文件之后,我迷失在如何使用它的目的。我在这里搜索,试图找到类似的问题和答案,没有运气,我也搜索了谷歌。任何人都可以协助改变这两行代码来利用MVNRND。谢谢!
我确实想弄清楚2个随机矩阵需要相互关联,如果有意义的话。 – balistikboy 2014-10-17 17:31:55