📄 berraylegh.m
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% All rights reserved by Krishna Pillai, http://www.dsplog.com% The file may not be re-distributed without explicit authorization% from Krishna Pillai.% Checked for proper operation with Octave Version 3.0.0% Author : Krishna Pillai% Email : krishna@dsplog.com% Version : 1.0% Date : 8 August 2008% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Script for computing the BER for BPSK modulation in a% Rayleigh fading channelclearN = 10^6 % number of bits or symbols% Transmitterip = rand(1,N)>0.5; % generating 0,1 with equal probabilitys = 2*ip-1; % BPSK modulation 0 -> -1; 1 -> 0 Eb_N0_dB = [-3:35]; % multiple Eb/N0 valuesfor ii = 1:length(Eb_N0_dB) n = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)]; % white gaussian noise, 0dB variance h = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)]; % Rayleigh channel % Channel and noise Noise addition y = h.*s + 10^(-Eb_N0_dB(ii)/20)*n; % equalization yHat = y./h; % receiver - hard decision decoding ipHat = real(yHat)>0; % counting the errors nErr(ii) = size(find([ip- ipHat]),2);endsimBer = nErr/N; % simulated bertheoryBerAWGN = 0.5*erfc(sqrt(10.^(Eb_N0_dB/10))); % theoretical berEbN0Lin = 10.^(Eb_N0_dB/10);theoryBer = 0.5.*(1-sqrt(EbN0Lin./(EbN0Lin+1)));% plotclose allfiguresemilogy(Eb_N0_dB,theoryBerAWGN,'cd-','LineWidth',2);hold onsemilogy(Eb_N0_dB,theoryBer,'bp-','LineWidth',2);semilogy(Eb_N0_dB,simBer,'mx-','LineWidth',2);axis([-3 35 10^-5 0.5])grid onlegend('AWGN-Theory','Rayleigh-Theory', 'Rayleigh-Simulation');xlabel('Eb/No, dB');ylabel('Bit Error Rate');title('BER for BPSK modulation in Rayleigh channel');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -