Getting Started | ![]() ![]() |
Simulating Noise with Specified Error Patterns
To use the model in the figure Using Data from the Workspace to Simulate Errors, you must first create a binary vector called errors
in the workspace to represent errors in the channel. A 1 in the vector represents an error in the channel, while a 0 represents no error. When you run a simulation, the Logical Operator block performs the XOR operation on the vector errors
and the signal.
For example, to create a vector of length 7x104 that contains exactly one 1
in each sequence of entries from 7n + 1 to 7(n + 1), enter the following at the MATLAB prompt.
The function randperm
generates a random permutation of the numbers one through seven. The vector v(p)
applies the permutation to the entries of the vector v
, which has exactly one entry that is 1
. The result is that the vector errors
contains exactly one entry that is 1
in each sequence from 7n + 1 to 7(n+1).
Running a Simulation with Imported Error Data
When you run a simulation, the bit error rate is zero because the Hamming code can correct one error in each code word.
To test the code with an error vector that creates two errors in each code word, just change the vector v
to v=[1 1 0 0 0 0 0]
in the preceding code.
![]() | Simulating Noise with Imported Data | Setting Sample Times and Samples per Frame | ![]() |