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

📄 wcl_ss_pe.m

📁 Hybrid DS-FH communication systems
💻 M
字号:
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%
% 	Finds the measured error rate given value of the snr_in_dB, Lc, A, w0.
%	
% 	Copyright(c) 2009-2015 HanYang University Wireless Communication Lab
% 
% 	Date		Name            Version         Description
%   ----------  -----------     -----------     ---------------------------
% 	2009.05.22	JINMINGSONG     v1.00           Create
% 	2009.05.23	JINMINGSONG     v1.01           Upgrade
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function [p] = WCL_ss_pe(snr_in_dB, Lc, A, w0)
snr=10^(snr_in_dB/10);
sgma=1;                 % Noise standard deviation is fixed.
Eb=2*sgma^2*snr;        % signal level required to achieve the given 
		      			% signal-to-noise ratio
E_chip=Eb/Lc;           % energy per chip
N=1000000;                % number of bits transmitted
% The generation of the data, noise, interference, decoding process and error
% counting is performed all together in order to decrease the run time of the 
% program. This is accomplished by avoiding very large sized vectors.
num_of_err=0;		
for i=1:N,
    % Generate the next data bit.
    temp=rand;	
    if (temp<0.5),
        data=-1;
    else
        data=1;
    end;
    % Repeat it Lc times, i.e. divide it into chips.
    for j=1:Lc,
        repeated_data(j)=data;
    end;
    % create pn sequence matrix and choose one line
    k = mod(i, Lc)
    if (k==0)
        k=Lc
    end
    if (k==1)
        pn_seq_matrix = WCL_mseq(5, [2,5], [1,1,1,1,1]); 
    end
    pn_seq = pn_seq_matrix(k,:);
    % the transmitted signal is
    trans_sig=sqrt(E_chip)*repeated_data.*pn_seq;
    % AWGN with variance sgma^2
    noise=sgma*randn(1,Lc);
    % interference 
    n=(i-1)*Lc+1:i*Lc;
    interference=A*sin(w0*n);
    % received signal
    rec_sig=trans_sig+noise+interference;
    % Determine the decision variable from the received signal.
    temp=rec_sig.*pn_seq;
    decision_variable=sum(temp);
    % making decision
    if (decision_variable<0),
        decision=-1;
    else
        decision=1;
    end;
    % If it is an error, increment the error counter.
    if (decision~=data),
        num_of_err=num_of_err+1;
    end;
end;
% then the measured error probability is
p=num_of_err/N;

⌨️ 快捷键说明

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