| Communications Toolbox | ![]() |
The script below uses the symerr function to compute the symbol error rates for a noisy linear block code. After artificially adding noise to the encoded message, it compares the resulting noisy code to the original code. Then it decodes and compares the decoded message to the original one.
m = 3; n = 2^m-1; k = n-m; % Prepare to use Hamming code. msg = randint(k*200,1,2); % 200 messages of k bits each code = encode(msg,n,k,'hamming'); codenoisy = rem(code+(rand(n*200,1)>.95),2); % Add noise. % Decode and correct some errors. newmsg = decode(codenoisy,n,k,'hamming'); % Compute and display symbol error rates. [codenum,coderate] = symerr(code,codenoisy); [msgnum,msgrate] = symerr(msg,newmsg); disp(['Error rate in the received code: ',num2str(coderate)]) disp(['Error rate after decoding: ',num2str(msgrate)])
The output is below. The error rate decreases after decoding because the Hamming decoder corrects some of the errors. Your results might vary because the example uses random numbers.
Error rate in the received code: 0.054286 Error rate after decoding: 0.03
| Using Simulated Data to Compute Bit and Symbol Error Rates | Comparison of Symbol Error Rate and Bit Error Rate | ![]() |
© 1994-2005 The MathWorks, Inc.