Comparison of C++ and MATLAB Using Object Oriented Application Example

This example calculates the bit error rate (BER) of a Bluetooth or 802.11b communication link interfered with by another 802.11b or Bluetooth transmitter. It uses the new MATLAB object oriented programming features released in R2008a.

The main function btint and accompanying classes have been translated from the C++ NIST Bluetooth and IEEE 802.11b Coexistence Simulator. The original C++ code has been retained as comments in the MATLAB code to help with its understanding for those familiar with C++.

In same cases, the MATLAB code has been written in a style to more closely match the C++ code. Additional MATLAB language features could be used in those circumstance to improve efficiency or understandability.

Contents

Setup

Put the folder containing these files on your path. This avoids problems which can occur if you change folders, taking class definitions out of scope, while you have objects based on them defined in the workspace.

Running the Simulation

The btint function calculates the BER of a system specified by the input arguments. It takes all string parameters to copy the behavior of the equivalent C main function. We will call the function with a couple of different configurations using this subset of arguments:

1) Bluetooth interfered by 802.11b, noise level 0, 5 packets

btint -d BT -i 802.11 -EbNo 0 -c 5;
Desired signal transmitter/receiver: BT.
Interference transmitter: 802.11.
Number of packets = 5.
Packet length = 160.
Frequency offset (MHz)=   4
Carrier-to-interference ratio (dB) = 100.
Carrier-to-noise ratio (dB) = 0.
Number of bit errors = 233.
BER = 3.03e-001.

2) 802.11b, 11Mbps rate, interfered by Bluetooth, noise level 0, 40 packets

btint -d 802.11 -bd 11 -i BT -EbNo 0  -c 40;
Desired signal transmitter/receiver: 802.11.
Interference transmitter: BT.
Number of packets = 40.
Packet length = 176.
Frequency offset (MHz)=   4
Carrier-to-interference ratio (dB) = 100.
Carrier-to-noise ratio (dB) = 0.
Number of bit errors = 996.
BER = 1.50e-001.

For a list of all available parameters see the NIST web site.

Application Overview

The application is made up of the following functions and classes.

Functions

Classes

Things to Investigate

Other Resources for Learning Object Orient Programming in MATLAB