time_fad.m

来自「This is the code for Rayleigh fading sim」· M 代码 · 共 28 行

M
28
字号
% Create Rayleigh fading channel object.
chan = rayleighchan(1/10000,500);

% Generate data and apply fading channel.
M = 2; % DBPSK modulation order
tx = randint(50000,1,M);  % Random bit stream
dpskSig = dpskmod(tx,M);  % DPSK signal
fadedSig = filter(chan,dpskSig); % Effect of channel
chan  %Display Channel Properties

% Compute error rate for different values of SNR.
SNR = 0:2:20; % Range of SNR values, in dB.
for n = 1:length(SNR)
   rxSig = awgn(fadedSig,SNR(n)); % Add Gaussian noise.
   rx = dpskdemod(rxSig,M); % Demodulate.
   % Compute error rate.
   % Ignore first sample because of DPSK initial condition.
   [nErrors, BER(n)] = biterr(tx(2:end),rx(2:end));
end

% Compute theoretical performance results, for comparison.
BERtheory = berfading(SNR,'dpsk',M,1);

% Plot BER results.
semilogy(SNR,BERtheory,'b-',SNR,BER,'r*');
legend('Theoretical BER','Empirical BER');
xlabel('SNR (dB)'); ylabel('BER');
title('Binary DPSK over Rayleigh Fading Channel');

⌨️ 快捷键说明

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