comp_exam4_1.m
来自「the source code of Ziemer s book Digital」· M 代码 · 共 20 行
M
20 行
% Simulation the probability of more than N_errors in N symbol blocks in
% a digital communication system
%
N_sim = input('Enter number of repetitions or trials ');
N = input('Bit block size for simulation ');
N_errors = input('Simulate the probability of more than __ errors occurring ');
PE = input('Error probability on each bit ');
count = 0;
for n = 1:N_sim
U = rand(1, N);
Error = (-sign(U-PE)+1)/2; % Error array - elements are 1 for error; 0 otherwise
if sum(Error) > N_errors
count = count + 1;
end
if mod(n,1000) == 0
n
end
end
P_greater = count/N_sim
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?