| Communications Toolbox | ![]() |
Here are some tips for preparing a Simulink model for use with BERTool:
To avoid using an undefined variable name in the dialog box for a Simulink block in the steps that follow, set up variables in the MATLAB workspace using a command such as the one below.
EbNo = 0; maxNumErrs = 100; maxNumBits = 1e8;
You might also want to put the same command in the model's preload function callback, to initialize the variables if you reopen the model in a future MATLAB session.
When you use BERTool, it provides the actual values based on what you enter in the GUI, so the initial values above are somewhat arbitrary.
To model the channel, use the AWGN Channel block in the Communications Blockset with these parameters:
Mode = Signal to noise ratio (Eb/No)
Eb/No = EbNo

To compute the error rate, use the Error Rate Calculation block in the Communications Blockset with these parameters:
Check Stop simulation.
Target number of errors = maxNumErrs
Maximum number of symbols = maxNumBits

To send data from the Error Rate Calculation block to the MATLAB workspace, set Output data to Port, attach a Signal to Workspace block from the Signal Processing Blockset, and set the latter block's Limit data points to last parameter to 1. The Variable name parameter in the Signal to Workspace block must match the value you enter in the BER variable name field of BERTool.
If your model computes a symbol error rate instead of a bit error rate, then use the Integer to Bit Converter block in the Communications Blockset to convert symbols to bits.
Frame-based simulations often run faster than sample-based simulations for the same number of bits processed. Note that the number of errors or number of processed bits might exceed the values that you enter in BERTool, because the simulation always processes a fixed amount of data in each frame.
If you have an existing model that uses the AWGN Channel block using a Mode parameter other than Signal to noise ratio (Eb/No), then you can adapt the block to use the Eb/No mode instead. To learn about how the block's different modes are related to each other, press the AWGN Channel block's Help button to view the online reference page.
If your model uses a preload function or other callback to initialize variables in the MATLAB workspace upon loading, then make sure before you use the Run button in BERTool that one of these conditions is met:
The model is not currently in memory. In this case, BERTool loads the model into memory and runs the callback functions.
The model is in memory (whether in a window or not), and the variables are intact.
If you clear or overwrite the model's variables and want to restore their values before using the Run button in BERTool, then you can use the bdclose function in the MATLAB Command Window to clear the model from memory. This causes BERTool to reload the model after you press Run. Similarly, if you refresh your workspace by issuing a clear all or clear variables command, then you should also clear the model from memory by using bdclose all.
| Requirements for Models | Example: Preparing a Model for Use with BERTool | ![]() |
© 1994-2005 The MathWorks, Inc.