| Communications Toolbox | ![]() |
This example starts from a Simulink model originally created as an example in the Communications Blockset Getting Started documentation, and shows how to tailor the model for use with BERTool. The example also illustrates how to compare the BER performance of a Simulink simulation with theoretical BER results. The example assumes that you have the Communications Blockset installed.
To prepare the model for use with BERTool, follow these steps, using the exact case-sensitive variable names as shown:
Open the model by entering the following command in the MATLAB Command Window.
bpskdoc

To initialize parameters in the MATLAB workspace and avoid using undefined variables as block parameters, enter the following command in the MATLAB Command Window.
EbNo = 0; maxNumErrs = 100; maxNumBits = 1e8;
To ensure that BERTool uses the correct amount of noise each time it runs the simulation, open the dialog box for the AWGN Channel block by double-clicking the block. Set Es/No to EbNo and click OK. In this particular model, Es/N0 is equivalent to Eb/N0 because the modulation type is BPSK.
To ensure that BERTool uses the correct stopping criteria for each iteration, open the dialog box for the Error Rate Calculation block. Set Target number of errors to maxNumErrs, set Maximum number of symbols to maxNumBits, and click OK.
To enable BERTool to access the BER results that the Error Rate Calculation block computes, insert a Signal to Workspace block in the model and connect it to the output of the Error Rate Calculation block.
Note The Signal to Workspace block is in the Signal Processing Blockset and is different from the To Workspace block in Simulink. |

To configure the newly added Signal to Workspace block, open its dialog box. Set Variable name to BER, set Limit data points to last to 1, and click OK.

(Optional) To make the simulation run faster, especially at high values of Eb/N0, open the dialog box for the Bernoulli Binary Generator block. Check Frame-based outputs and set Samples per frame to 1000.
Save the model in a directory on your MATLAB path, using the filename bertool_bpskdoc.mdl.
(Optional) To cause Simulink to initialize parameters if you reopen this model in a future MATLAB session, enter the following command in the MATLAB Command Window and then resave the model.
set_param('bertool_bpskdoc','preLoadFcn',...
'EbNo = 0; maxNumErrs = 100; maxNumBits = 1e8;');
The bertool_bpskdoc model is now compatible with BERTool. To use it in conjunction with BERTool, continue the example by following these steps:
Open BERTool and go to the Monte Carlo panel.
Set parameters on the Monte Carlo panel as shown below.

Click Run.
BERTool spends some time computing results and then plots them.

To compare these simulation results with theoretical results, go to the Theoretical panel in BERTool and set parameters as shown below.

Click Plot.
BERTool plots the theoretical curve in the BER Figure window along with the earlier simulation results.

| Tips for Preparing Models | Managing BER Data | ![]() |
© 1994-2005 The MathWorks, Inc.