cp0801_gnoise1.m

来自「详细介绍超宽带无线电的各个模块和MATLAB实现」· M 代码 · 共 39 行

M
39
字号
%
% FUNCTION 8.2 : "cp0801_Gnoise1"
%
% Introduces additive white Gaussian noise over signal
%  'input'.
% Vector 'ebno' contains the target values of Eb/No (in dB)
% 'numbits' is the number of bits conveyed by the input
%  signal
% 
% Multiple output signals are generated, one signal for
% each target value of Eb/No. The array 'output' contains
% all the signals (input+AWGN), one signal per row.
% The array 'noise' contains the different realization of
% the Gaussian noise, one realization per each row
%
% Programmed by Guerino Giancola
%

function [output,noise] = ...
   cp0801_Gnoise1(input,ebno,numbits)

% -------------------------------
% Step One - Introduction of AWGN
% -------------------------------

Eb = (1/numbits)*sum(input.^2); % measured energy per bit
EbNo = 10.^(ebno./10);          % Eb/No in linear unit     
No = Eb ./ EbNo;                % Unilateral spectral
                                % density
nstdv = sqrt(No./2);            % Standard deviation for
                                % the noise

for j = 1 : length(EbNo)
        
    noise(j,:) = nstdv(j) .* randn(1,length(input));
    output(j,:) = noise(j,:) + input;
    
end

⌨️ 快捷键说明

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