Products & Services Solutions Academia Support User Community Company

Learn more about Communications Toolbox   

Running MATLAB Simulations

Section Overview

You can use BERTool in conjunction with your own MATLAB simulation functions to generate and analyze BER data. The MATLAB function simulates the communication system whose performance you want to study. BERTool invokes the simulation for Eb/N0 values that you specify, collects the BER data from the simulation, and creates a plot. BERTool also enables you to easily change the Eb/N0 range and stopping criteria for the simulation.

To learn how to make your own simulation functions compatible with BERTool, see Preparing Simulation Functions for Use with BERTool.

Example: Using a MATLAB Simulation with BERTool

This example illustrates how BERTool can run a MATLAB simulation function. The function is viterbisim, one of the demonstration files included with Communications Toolbox software.

To run this example, follow these steps:

  1. Open BERTool and go to the Monte Carlo tab. (The default parameters depend on whether you have Communications Blockset™ software installed. Also note that the BER variable name field applies only to Simulink models.)

  2. Set parameters as shown in the following figure.

  3. Click Run.

    BERTool runs the simulation function once for each specified value of Eb/N0 and gathers BER data. (While BERTool is busy with this task, it cannot process certain other tasks, including plotting data from the other tabs of the GUI.)

    Then BERTool creates a listing in the data viewer.

    BERTool plots the data in the BER Figure window.

  4. To change the range of Eb/N0 while reducing the number of bits processed in each case, type [5 5.2 5.3] in the Eb/No range field, type 1e5 in the Number of bits field, and click Run.

    BERTool runs the simulation function again for each new value of Eb/N0 and gathers new BER data. Then BERTool creates another listing in the data viewer.

    BERTool plots the data in the BER Figure window, adjusting the horizontal axis to accommodate the new data.

    The two points corresponding to 5 dB from the two data sets are different because the smaller value of Number of bits in the second simulation caused the simulation to end before observing many errors. To learn more about the criteria that BERTool uses for ending simulations, see Varying the Stopping Criteria.

For another example that uses BERTool to run a MATLAB simulation function, see Example: Preparing a Simulation Function for Use with BERTool.

Varying the Stopping Criteria

When you create a MATLAB simulation function for use with BERTool, you must control the flow so that the simulation ends when it either detects a target number of errors or processes a maximum number of bits, whichever occurs first. To learn more about this requirement, see Requirements for Functions; for an example, see Example: Preparing a Simulation Function for Use with BERTool.

After creating your function, set the target number of errors and the maximum number of bits in the Monte Carlo tab of BERTool.

Typically, a Number of errors value of at least 100 produces an accurate error rate. The Number of bits value prevents the simulation from running too long, especially at large values of Eb/N0. However, if the Number of bits value is so small that the simulation collects very few errors, the error rate might not be accurate. You can use confidence intervals to gauge the accuracy of the error rates that your simulation produces; the larger the confidence interval, the less accurate the computed error rate.

As an example, follow the procedure described in Example: Using a MATLAB Simulation with BERTool and set Confidence Level to 95 for each of the two data sets. The confidence intervals for the second data set are larger than those for the first data set. This is because the second data set uses a small value for Number of bits relative to the communication system properties and the values in Eb/No range, resulting in BER values based on only a small number of observed errors.

Plotting Confidence Intervals

After you run a simulation with BERTool, the resulting data set in the data viewer has an active menu in the Confidence Level column. The default value is off, so that the simulation data in the BER Figure window does not show confidence intervals.

To show confidence intervals in the BER Figure window, set Confidence Level to a numerical value: 90%, 95%, or 99%.

The plot in the BER Figure window responds immediately to your choice. A sample plot is below.

For an example that plots confidence intervals for a Simulink simulation, see Example: Using a Simulink Model with BERTool.

To find confidence intervals for levels not listed in the Confidence Level menu, use the berconfint function.

Fitting BER Points to a Curve

After you run a simulation with BERTool, the BER Figure window plots individual BER data points. To fit a curve to a data set that contains at least four points, select the box in the Fit column of the data viewer.

The plot in the BER Figure window responds immediately to your choice. A sample plot is below.

For an example that performs curve fitting for data from a Simulink simulation and generates the plot shown above, see Example: Using a Simulink Model with BERTool. For an example that performs curve fitting for data from a MATLAB simulation function, see Example: Preparing a Simulation Function for Use with BERTool.

For greater flexibility in the process of fitting a curve to BER data, use the berfit function.

  


Free Early Verification Kit

Learn how to apply early verification to your development process through these technical resources.

How much time do you spend on testing to ensure implementation meets system-level requirements?

 © 1984-2010- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS