gngauss.m

来自「信道仿真的源文件」· M 代码 · 共 19 行

M
19
字号
function [gsrv1,gsrv2]=gngauss(m,sgma)% [gsrv1,gsrv2]=gngauss(m,sgma)% [gsrv1,gsrv2]=gngauss(sgma)% [gsrv1,gsrv2]=gngauss%		GNGAUSS  generates two independent Gaussian random variables with mean%   		m and standard deviation sgma. If one of the input arguments is missing %   		it takes the mean as 0, and the standard deviation as the given parameter.%   		If neither mean nor the variance is given, it generates two standard%   		Gaussian random variables. if nargin == 0,  m=0; sgma=1;elseif nargin == 1,  sgma=m; m=0;end;u=rand;  				% a uniform random variable in (0,1)       z=sgma*(sqrt(2*log(1/(1-u))));   	% a Rayleigh distributed random variableu=rand;  				% another uniform random variable in (0,1)       gsrv1=(m+z*cos(2*pi*u))/sqrt(2);gsrv2=(m+z*sin(2*pi*u))/sqrt(2);   

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?