⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gwnoise.m

📁 数字通信第四版原书的例程
💻 M
字号:
function [m, d, s] = gwnoise(m, d, s)
%GWNOISE generates a valid mean value, standard deviation and seeds for GWNOISE block.
%	[M, D, S] = GWNOISE(M, D, S) checks input mean M, standard deviation D, and
%	seed S. When they are not valid, converts them to be a valid one for GWNOISE
%	block, or gives out error mesasge.
%

%       Copyright (c) 1996 by The MathWorks, Inc.
%       $Revision: 1.1 $  $Date: 1996/04/01 19:39:22 $

if nargin ~= 3
	error('Input variable must be 3 for GWNOISE.');
end;
m = m(:)';
s = s(:)';
l_m = length(m);
l_s = length(s);
[n_d, m_d] = size(d);
if n_d ~= m_d
	if min(n_d, m_d) == 1
		if any(d < 0)
			error('Standard deviation cannot be negative number.');
		end
		d = diag(d);
	else
		error('Standard deviation for Gaussian noise block is not valid.');
	end;
else
	[n_d, m_d] = chol(d);
	if m_d ~= 0
		error('Standard deviation for Gaussian noise must be positive definite.');
	end;
end;
l_d = length(d);
if ((l_m < l_d) & (l_m ~= 1)) | ((l_m > l_d) & (l_d ~= 1))
	error('The dimention mean and standard deviation for Gaussin noise block is compactable.');
end;
max_l = max(l_m, l_d);
if l_s < max_l
	s = [s, max(s) + [1 : max_l - l_s]];
elseif l_s > max_l
	if max_l ~= 1
		s = s(1 : max_l);
	else
		d = eye(l_s) * d;
	end;
end;
[d, tmp] = chol(d);
if tmp > 0
    error('Covariance matrix in AWGN noise generator is not a positive defined matrix.');
end;
% end of gwnoise

⌨️ 快捷键说明

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