You are on page 1of 26

WIRELESS LAB REPORT

Bahir Dar University

Bahir Dar Institute of Technology

Faculty of Electrical and Computer Engineering

Stream of Communication and Electronics Engineering

Wireless and mobile communication lab report

Name ID

1. YordanosAdeme 1103056
2. TsegaMelese 1103290
3. TsionTesfaye 1103213
4. Wubegzer Lake 1102205
5. Yalemtibeb Addis 1103307
6. Fikresilassie Endalkachew 1102639
7. Mastewal Tibeb 1102443
8. Tesfalem Temesgen 1102510
9. Tibeb Getnet 1102700

February , 2022 Bahirdar, Ethiopia


WIRELESS LAB REPORT

Table of Contents

Part I............................................................................................................................................................3
Simulation of Wireless Communication Systems.........................................................................................3
Introduction.............................................................................................................................................3
Practical 1.1: Binary Random Data Generation..........................................................................................4
Theory.....................................................................................................................................................4
Practical 1.2: Digital Modulation of the Binary Random Data.....................................................................6
Theory.....................................................................................................................................................6
Modulation Techniques...........................................................................................................................6
Quadrature Amplitude Modulation (QAM).............................................................................................8
Plotting the Signal Constellation of this Modulator.................................................................................9
Annotate the Plot to Indicate the Mapping...........................................................................................10
Gray coded the modulator to minimize error............................................................................................11
Practical 1.3: Wireless Channel Modeling.................................................................................................12
Theory...................................................................................................................................................12
Creating the Wireless Channel Objects..................................................................................................14
Practical 1. 4: Adding the Effect of the Additive White Gaussian Noise (AWGN)......................................16
Theory...................................................................................................................................................16
Practical 1.5: Demodulation of the Received Signal..................................................................................18
Theory...................................................................................................................................................18
Practical 1.6: Compare the Bit Error Rate (BER) of the System..................................................................18
Theory...................................................................................................................................................18
Practical 2.1: Planning and Creating the Cells and Base Stations...............................................................19
Creating the Base Stations.....................................................................................................................23
Practical 2.2: Creating and Adding the Mobiles to the Cellular System.....................................................23

I
WIRELESS LAB REPORT

Part I
Simulation of Wireless Communication Systems
Introduction
The practical exercises covered in this lab session on wireless and mobile communication
systems are extremely basic and helpful in understanding the subject's main goal. These
applications strengthen the theoretical and practical ideas that engineering students find to be of
utmost importance. The themes of wireless and mobile communication systems, which are
created to be developed using Matlab software, are covered practically in this workbook. This
workbook mostly includes a pertinent documentation of the lab sessions.

Objectives
The objective of this laboratory is to understand the various parts of the wireless communication
systems and observe the related modulation quality measurements. As we progress, the students
will be familiar with the following basic concepts.

 Principle of random data or information generators


 Principle of various modulation types.
 Understanding power, spectral efficiency, and data rate tradeoffs.
 Comparison of various modulation types in terms of time envelope, spectral efficiency,
constellation and eye diagrams.
 The tradeoff between higher data rates and higher susceptibility to noise at higher orders
of modulation (like 64QAM).
 Impact of AWGN and Fading channels on modulation techniques.
 Analysis of the bit error rate (BER) of wireless communication system under the impact
of multipath fading and time spreading wireless channels
 Model for Wireless Communication Systems

1
WIRELESS LAB REPORT

Practical 1.1: Binary Random Data Generation


Theory
Every communication system has one or more signal sources. This lab section describes how to
use the Communications Toolbox to generate random signals, which are useful for simulating
signal sources. The conventional format for representing a signal in MATLAB is a vector or
matrix. This example uses the randint function to create a column vector that lists the successive
values of a binary data stream. The length of the binary data stream (that is, the number of rows
in the column vector) is arbitrarily. Then the code plots the histogram and the stem functions for
the data.

Function Used

 randint();
 stem();
 hist();
 Code

% Generate the random data using the signal source % Create a binary data stream as a column
vector and plot thefirst50 bits in a stem plot.
n=3e4;
x = randint(n,1); % Random binary data stream from the source figure(1) stem(x(1:50),'filled');
title('Random Bits');
xlabel('Bit Index');
ylabel('Binary Value');
n=3e4;
x = randint(n,1);
% Random binary data stream from the source figure (1) stem(x (1:50),'filled'); title ('Random
Bits'); xlabel('Bit Index'); ylabel('Binary Value');

2
WIRELESS LAB REPORT

Figure1. 1 Generate random bits

Binary Bit to Symbol (Decimal) Conversion

% used to convert the bits in x into k-bit symbols. % Reshape(x,m,n) returns the m-by-n matrix
% whose elements are taken column wise from x. % An error results if X doesn’t have M*N
elements. M=16; k=log2 (M); x1=reshape(x,k,length(x)/k).';

Figure1. 1 Convert the bits in x into k-bit symbols

3
WIRELESS LAB REPORT

Practical 1.2: Digital Modulation of the Binary Random Data


Theory

In most media for communication, only a fixed range of frequencies is available for
transmission. One way to communicate a message signal whose frequency spectrum does not fall
within that fixed frequency range, or one that is otherwise unsuitable for the channel, is to alter a
transmittable signal according to the information in your message signal. This alteration is called
modulation and it is the modulated signal that you transmit. The receiver then recovers the
original signal through a process called demodulation.

Modulation Techniques

The methods of modulation depend on whether the input signal is analog or digital. The table
below show the modulation techniques that Communication Toolbox software supports for
analog and digital signals respectively.

Table 1: Analog modulation techniques and their syntaxes

Analog Modulation Method Acronym Function

Amplitude Modulation AM ammod, amdemod

Frequency Modulation FM fmmod, fmdemod

Phase Modulation PM pmmod, pmdemod

Single Sideband Amplitude SSB ssbmod, ssbdemod


Modulation

Steps of Modulating the Signal

Modulation is a process by which a carrier signal is altered according to information in a


message signal. The frequency of the carrier signal is usually much greater than the highest
frequency of the input message signal.

4
WIRELESS LAB REPORT

The Nyquist sampling theorem requires that the sampling rate, fs, should be greater than two
times the sum of the carrier frequency and the highest frequency of the modulated signal in order
for the demodulator to recover the message correctly.

The basic procedure for modulating a signal with MPSK and MQAM involves the following
steps:

1. Construct a modulator object depending on your modulation type.

2. Adjust properties of the modulator object, if necessary, to tailor it to your needs. For
example, you can change the phase offset or symbol order.
3. Modulate your signal by applying the modulate method of the modulator object, as
described in the following section.

Similarly the basic procedure for demodulating a signal with MPSK and MQAM involves the
following steps:

1. Construct a demodulator object depending on your modulation type.

2. Adjust properties of the demodulator object, if necessary, to tailor it to your needs. For
example, you can change the phase offset or symbol order.
3. Demodulate your signal by applying the demodulate method of the demodulator object,
as described in the following section.
Quadrature Amplitude Modulation (QAM)
In this laboratory, we will use QAM techniques that you have learnt in digital communication.
Modulate Using MQAM: having defined xsym as a column vector containing integers between 0
and M where M is the alphabet size and must be an integer power of two. The message signal
must consist of integers between 0 and M-1. Therefore, if the random source is in binary, we
must preprocess the binary data stream x before using the modulate method of the object. In
particular, you arrange each tuple of values from x across a row of a matrix, using the reshape
function in MATLAB, and then apply the bi2de function to convert each k-tuple to a
corresponding integer.

Function Used:

 modem.qammod();
5
WIRELESS LAB REPORT

 modem.qamdemod();
Define the Modulating Object

Generally we use the modulation object that we have shown in the tables 1.1 and 1.2 above to
modulate the signal. In this case, we can change the property of the modulation parameters
according to our design specifications. The command: hmod = modem.qammod (M)
Constructs a QAM modulator object hmod for M-ary modulation. The properties that are unique
to the QAM modulator object are set to default values. A QAM modulator object has the
following properties. All the properties are writable except for the ones explicitly noted
otherwise.

 Type: - Type of modulation object ('QAM Modulator'). This property is not writable.
 M: - M-ary value.
 Phase Offset - Phase offset of ideal signal constellation in radians.
 Constellation- Ideal signal constellation. This property is not writable and is
automatically computed based on M and Phase Offset properties.
 Symbol Order- Type of mapping employed for mapping symbols to ideal constellation
points. The choices are:

 'binary' - for Binary mapping

 'Gray' - for Gray mapping.

Gray mapping is a modulation technique in which the corresponding adjacent bits sequences are
differ by one bit. This mapping technique is used to reduce the probability of BER in the
communication system. For the PSK, DPSK, FSK, QAM, and PAM modulation types, Gray
constellations are obtained by selecting the Gray parameter in the corresponding modulation
function or method. For modulation objects, you can set the symbol order property to Gray to
obtain Gray-encoded modulation.

 'user-defined' - for custom mapping

6
WIRELESS LAB REPORT

Symbol Mapping: Symbol mapping is a list of integer values from 0 to M-1 that correspond to
ideal constellation points. This property is writable only when Symbol Order is set to 'user-
defined'; otherwise it is automatically computed.

Input Type: - Type of input to be processed by QAM modulator object. The choices are:

 'bit' - for bit/binary input


 'integer' - for integer/symbol input

Example: 16-QAM Modulator Object Definition

M= 16; %Numberofpointsinconstellation
h=modem.qammod(M); %
Modulator object mapping=h.SymbolMapping
% Symbol mapping vector pt = h.Constellation; % Vector
of all points in constellation

Plotting the Signal Constellation of this Modulator


The Constellation property of the modem.qammod object contains all points in the 16QAM
signal constellation. scatterplot(pt);

Figure1. 2 Scatter Plot of the Modulator Object

7
WIRELESS LAB REPORT

Annotate the Plot to Indicate the Mapping


To annotate the plot to show the relationship between mapping and pt, use the text function to
place a number in the plot beside each constellation point. The coordinates of the annotation are
near the real and imaginary parts of the constellation point, but slightly offset to avoid overlap.
The text of the annotation comes from the binary representation of mapping. (The dec2bin
function in MATLAB produces a string of digit characters, while the de2bi function used in the
last section produces a vector of numbers.). Include text annotations that number the points.
text(real(pt)+0.1,imag(pt),dec2bin(mapp ing)); axis([-4 4 -4 4]);

% Change axis so all labels fit in plot.

Figure1. 4Binary-Coded 16-QAM Signal Constellation

Gray coded the modulator to minimize error


In the plot above, notice that 0001 and 0010 correspond to adjacent constellation points on the
left side of the diagram. Because these binary representations differ by two bits, the adjacent
indicates that the modem.qammod object did not use a Gray-coded signal constellation.

(That is, if it were a Gray-coded signal constellation, then the annotations for each pair of
adjacent points would differ by one bit.). Figure below shows Gray-coded 16QAM signal
constellation.

8
WIRELESS LAB REPORT

Code

% modified Plot with Gray Coding M = 16;

% Number of points in constellationh =

modem.qammod('M',M,'SymbolOrder','Gray');

% Modulator object mapping =h.SymbolMapping;

% Symbol mapping vector pt = h.Constellation;

% Vector of all points in constellation scatterplot(pt);

% Plot the constellation. % Include text annotations that number the points. text(real(pt)
+0.1,imag(pt),dec2b in(mapping)); axis([-4 4 -4 4]); % Change axis so all labels fit in plot.

Figure1. 5 Gray-Coded 16-QAM Signal Constellation

Modulate the Data with the Modulator

Modulator objects have a method modulate that is used to modulate signals. The syntax is y =
modulate (h, x), where h is the handle to a modulator object and x is a signal. When mapping
input bits to symbols, the first bit is interpreted as the most significant bit. For h.inputtype = `bit'
(i.e., x represents binary input), nBits consecutive elements in each channel or column represent
a symbol, where nBits =log2 (M). For h.inputtype = `integer' (i.e., x represents symbol input),
elements of x must be in the range [0, M-1].

9
WIRELESS LAB REPORT

% Modulate the Data symbol hmod=h;

tx=modulate(hmod,xsym); % where xsym is used from previous sections

Practical 1.3: Wireless Channel Modeling


Theory
The Rayleigh and Rician fading channel distributions are useful models of real-world
phenomena in wireless communication. These phenomena include multipath scattering effects,
time dispersion, and Doppler shifts that arise from relative motion between the transmitter and
receiver. These parameters are defined as follows:

❖The maximum Doppler shift is computed as v*f/c, where v is the mobile speed, f is the carrier
frequency, and c is the speed of light. For example, a maximum Doppler shift of 200 Hz (as
above) corresponds to a mobile speed of 30 m/s and a carrier frequency of 2 GHz.

❖By convention, the delay of the first path is typically set to zero. For subsequent paths, a 1
microsecond delay corresponds to a 300 m difference in path length. In some outdoor multipath
environments, reflected paths can be up to several kilometers longer than the shortest path. With
the path delays specified above, the last path is 3.6 km longer than the shortest path, and thus
arrives 12 microseconds later. Together, the path delays and path gains specify the channel's
average delay profile.

❖Typically, the average path gains decay exponentially with delay (i.e., the dB values decay
linearly), but the specific delay profile depends on the propagation environment. In the delay
profile specified above, we assume a 3 dB decrease in average power for every 4 microseconds
of path delay. The Doppler shift of the specular component is typically smaller than the
maximum Doppler shift (above) and depends on the mobile's direction of travel relative to the
direction of the specular component. The K-factor specifies the linear ratio of average received
power from the specular component relative to that of the associated diffuse components.

In this laboratory we will use these types of fading channel distribution. To process a signal
using a fading channel involves the following steps:

10
WIRELESS LAB REPORT

❖Create a channel object that describes the channel that you want to use. A channel object is a
type of MATLAB variable that contains information about the channel such as the symbol
period, maximum Doppler shift, multipath component and other parameter.

❖Adjust properties of the channel object, if necessary, to tailor it to your needs. For example,
you can change the path delays or average path gains.

❖Apply the channel object to your signal using the filter function, which has been overloaded to
work with channel objects.

Functions Used

1. Rayleigh and Rician multipath fading channel objects


2. Channel visualization tool

Define the Wireless Channel Parameters

The following variables control both the Rayleigh and Rician channel objects. By default, the
channel is modeled as four fading paths, each representing a cluster of multipath components
received at around the same delay.

Code

Ts= 1/500000;

% Sample time (sec) kf=10;

% Rican k-factors

sds=100 % Specific Doppler Shift for Rican fading distribution fd = 200;

% Maximum Doppler shift of diffuse components (Hz)

tau= 1.0e-004 * [0 0.0400 0.0800 0.1200];

% Discrete delays of four-path channel (sec)

pdp = [0 -3 -6 -9]; % Average path gains (dB)

11
WIRELESS LAB REPORT

Creating the Wireless Channel Objects


With the parameters specified above, we can now create the Rayleigh and Rician channel objects
using the Rayleighchan and Ricianchan functions.

% Create Rayleigh channel object

Raychan = rayleighchan(Ts, fd, tau,pdp) ;

Raychan.StoreHistroy = 1; % Store channel state information for later visualization

% Create Rician channel object

Richan = ricianchan(Ts, fd, kf, tau, pdp, sds); Richan.StoreHistory = 1;

% Store channel state information for later visualization

Filter the Signal by Using the Wireless Channel

The wireless channel is considered as the linear time variant channel. Thus after we create the
wireless channel object and adjust the parameters, the next step that we do is to filter the
modulate signal with the wireless channel by using the following commands:

% filter the modulated signal with the wireless channel txc=filter(Raychan,tx);

Channel Object Animation and Visualization

The Communications Toolbox provides a plotting function that helps you visualize the
characteristics of a fading channel using a GUI. The channel visualization tool can be invoked by
the CHANNEL_VIS function. Using option 'IR' opens the visualization for the band limited
impulse response (green curve). The visualization also shows the delays and magnitudes of the
underlying fading path gains (red/magenta/blue stembars) clustered around the peak of the
impulse response. Components with intermediate delay values are shades between red and blue,
becoming bluer for larger delays.

channel_vis(Raychan, % View Impulse

'Visualization','ir'); Response

channel_vis(Raychan, 'Animation', % Set animation


12
WIRELESS LAB REPORT

'medium'); speed

channel_vis(Raychan, 'SampleIndex', 1); % Set animation start point

Note: In this plot, the gains may not be equal the average path gains because the Doppler Effect
causes the gains to fluctuate around their average values over time.

Figure1. 6Multipath fading channel gains

Practical 1. 4: Adding the Effect of the Additive White Gaussian Noise


(AWGN)
Theory
An AWGN channel adds white Gaussian noise to the signal that passes through it. To model this
channel, use the AWGN function. The relative power of noise in an AWGN channel is typically
described by quantities such as:

❖Signal-to-noise ratio (SNR) per sample. This is the actual input parameter to the AWGN
function.

❖Ratio of bit energy to noise power spectral density (Eb/N0). This quantity is used by BER
Tool and performance evaluation functions in this toolbox.

❖Ratio of symbol energy to noise power spectral density (Es/N0)

❖The relationship between Es/N0 and Eb/N0, both expressed in dB, is as follows:

13
WIRELESS LAB REPORT

❖Es/N0 (dB) = Eb/N0(dB) + 10log10 (k) where k is the number of information bits per symbol.
In a communication system, k might be influenced by the size of the modulation alphabet or the
code rate of an error-control code. For example, if a system uses a rate-1/2 code and 8-PSK
modulation, then the number of information bits per symbol (k) is the product of the code rate
and the number of coded bits per modulated symbol: (1/2) log2(8) = 3/2. In such a system, three
information bits correspond to six coded bits, which in turn correspond to two 8-PSK symbols.
The relationship between Es/N0 and SNR, both expressed in dB, is as follows:

❖ Es/N0 (dB) = 10log10 (Tsym / Tsamp ) + SNR (dB) , for complex input signals

❖Es/N0 (dB) = 10log10 (0.5Tsym / Tsamp ) + SNR (dB), for real input signals where Tsym is
the signal’s symbol period and Tsamp is the signal’s sampling period. For example, if a complex
baseband signal is oversampled by a factor of 4, then Es/N0 exceeds the corresponding SNR by
10 log10 (4).

❖Adding additive white noise to the transmitted signal that passes through the fading channel

Snr=10; txn=awgn(txc,snr, 'measured');


Eye Diagram Plots

An eye diagram is simple and convenient tools for studying the effects of inter symbol
interference and other channel impairments in digital transmission. To construct an eye diagram,
plot the received signal against time on a fixed time interval axis. At the end of the fixed time
interval, wrap around to the beginning of the time axis. The resulting diagram consists of many
overlapping curves.

Eye Diagram of the Noisy Signal

yrx=txn ;

eyediagram(yrx,8);

Code

% Scatter plot of the original and noisy signal % Create scatter plot of noisy signal and
transmitted signal on the same axes. h = scatterplot(yrx(1:nsamp*5e3),nsamp,0,'g.'); hold on;

14
WIRELESS LAB REPORT

scatterplot(txc(1:5e3),1,0,'k*

',h); title('Received Signal'); legend('Received Signal','Signal

Constellation'); axis([-5 5 -5 5]); % Set axis ranges. hold off;

Practical 1.5: Demodulation of the Received Signal


Theory
Demodulator objects have a method demodulate that is used to demodulate signals.

The syntax is y = demodulate (h, x), where h is the handle to a demodulator object and x is a
signal. This syntax processes the binary words (bits) or symbols (integers) in signal x with the

QAM demodulator object and output the baseband signal y. The demodulator object’s property
Decision Type should be set depending on whether you want hard or soft decisions. To allow for
soft decisions, the demodulator object’s property Output Type must be set to 'bit'. In the next
section we will see the principle of QAM modulation.

Demodulation of the Received Signal

Code

% Demodulate the signal using 16-QAM hdemod=modem.qamdemod(M); zsym =


demodulate(hdemod,yrx);

% Symbol-to-Bit Mapping

% Undo the bit-to-symbol mapping performed earlier. z = de2bi(zsym,'leftmsb'); % Convert


integers to bits. % Convert z from a matrix to a vector. z = reshape(z.',prod(size(z) ),1);

15
WIRELESS LAB REPORT

Practical 1.6: Compare the Bit Error Rate (BER) of the System
Theory
In communication system, the receiver side BER may be affected by transmission channel noise,
interference, distortion, bit synchronization problems, attenuation, wireless multipath fading, etc.
BER may be improved by choosing a strong signal strength (unless this causes cross-talk and
more bit errors), by choosing a slow and robust modulation scheme or line coding scheme, and
by applying channel coding schemes such as redundant forward error correction codes.
The transmission BER is the number of detected bits that are incorrect before error correction,
divided by the total number of transferred bits (including redundant error codes). The
information BER, approximately equal to the decoding error probability, is the number of
decoded bits that remain incorrect after the error correction, divided by the total number of
decoded bits (the useful information). Normally the transmission BER is larger than the
information BER. The information BER is affected by the strength of the forward error
correction code.

Code

% Compute the BER of the system

% Compare x and z to obtain the number of errors and the bit error rate.

[number_of_errors, bit_error_rate] = biterr(x,z);

Conclusion

This Wireless and Mobile Communication Systems laboratory covers practical’s that are very
fundamental and quite relevant in grasping the core objective of the subject. These practical
solidify the theoretical and practical concepts that are very essential for the engineering students.
The objective of this laboratory is to understand the various parts of the wireless communication
systems and observe the related modulation quality measurements.

This laboratory report is prepared for wireless and mobile communication laboratory session.it
covers fundamental concepts on wireless and mobile communications systems which are
designed and developed on Matlab software.

16
WIRELESS LAB REPORT

Part II

Cellular System Simulation with Rudimentary Network Emulator

(RUNE)

Practical 2.1: Planning and Creating the Cells and Base Stations
1. Introduction

Rudimentary Network Emulator is a set of Matlab functions that makes it possible to simulate
cellular networks. RUNE provides functions that handle various aspects in cellular systems that
are mobiles, base stations, propagation loss, interference and mobility.

The functions are structured in the following folders:

 Runetools: general purpose functions (e.q. matrix handling)


 Runegain: functions needed for simulating any kind of cellular system. Generates the
gain matrix
 Runetdma: algorithms specific for TDMA system simulation
 Examples: examples of how to use RUNE
 Setpath : sets the Matlab path for simulations
 Setp : Wrapper for setpath that can be run without being on the path

2. Objective

 The objective of these laboratories is therefore to provide introduction to the most


commonly used parts of RUNE.
 create small simulation program that simulates a cellular system,
 creates some mobiles in that system.

3. Procedure

I. Creating Sites (Cells)

The first step in our cellular system simulation was to create cells. RUNE provides a function for
this purpose. It is called crecell.

17
WIRELESS LAB REPORT

Example: we created the hexagonal cells by using the commands:

[xyb, fib, rhombvec]=crecells (1000, 1, 1, 1, 1);

plothex(xyb, fib);

The first line of the code will create three omnidirectional cells with a radius of 1000m. Then the
second line will create a plot of the three base stations.

a. Input parameters for the crecells argument:

 The first input parameter to crecell is the cell radius. The second parameter is the number
of sectors per site. This will be one for omnidirectional antenna and three for sector
directional antenna.
 There are three more arguments to the function crecell. They are: km, lm, and ncluster.
These parameters are used to set the reuse factor and the size of the system. km and lm
indicates the number of cells in the U and V directions and ncluster indicates the cluster
repetition.

b. Output parameters for the crecells argument:

This function returns three data structures: xyb, fib, and rhombvec where;

 xyb: contains the positions of the base stations in complex numbers where the real part
represents the east-west direction and the imaginary part represents the north-south
direction.
 fib: contains the position of the base station from the center of the hexagonal cell. The fib
vector contains the direction of the main lobe of the base station antenna. For each base
station position there is a corresponding direction of the main antenna lobe. The value is a
vector that points from the base station to the middle of the cell. For omnidirectional base
station the distance from the base station to the center of the cell is zero.
 rhombvec: contains the size of the rhombus that represents the service area of the system
that is simulated.

18
WIRELESS LAB REPORT

Figure 2. 1 The cells created by the above commands

The creation of a cellular system is done in two steps. First one cluster is created. The

cluster concept is closely coupled to reuse in cellular systems. One cluster contains a

number of cells and all the cells use different channels. The next step is to copy the

cluster ncluster2 times and lay the clusters out next to each other. we wrote the following
commands inorder to create and analyze the clusters.

ex_crecell(2,1); This illustrates how a cluster with N cells is built. The parameters km and lm can
be input to the function of ex_cell and here km=2 and lm=1.

Figure 2. 2 Four clusters fitted together

19
WIRELESS LAB REPORT

Creating the Base Stations


Then we combined the above codes and we wrote the simulation program. The simulation
program should create a number of base stations. Then add the code that plots the cells.

Codes to create the base station and to plote the system:

To Create the base stations:

par.cellradius=1000;

par.sps=1;

par.km=1;

par.lm=2;

par.ncluster=1;

[xyb,fib,rhombvec]=crecells(par.cellradius, par.sps, par.km, par.lm, par.ncluster)

To Plot the system

figure(1);

C=[0.1, 0.6,0.3, 0.8, 0.4, 0.2,0.9]; % shows the colour of the cell

plothex(xyb,fib,C);

Practical 2.2: Creating and Adding the Mobiles to the Cellular System
The next step in the cellular system simulation is to create a number of mobiles. In RUNE,
mobiles are represented by a number of vectors in the first dimension (column vectors). Data
belonging to one mobile is found at the same position in each vector. The return vector contains
the number of mobiles (m), the mobile position (xym) and the velocity of the mobile (xyv). The
name of the vectors can of course be anything, but for simplicity they are designated as m, xym,
and xyv.

20
WIRELESS LAB REPORT

The function responsible for positioning the mobiles and moving them around is called
mobmove. The idea is that if a mobile doesn’t have a position it is given positon, and if the
mobile already has a position it can move a small distance. The reason for this is that mobmove
often work with both mobiles that have been in the system some time and new ones
simultaneously. When a mobile hasn’t been given position it is marked by setting the position
xym to nan.

Procedures

 Create few mobiles and give them a position by using the commands:

nmob=10;

xym=nans(nmob,1);

xyv=nans(nmob,1);

m=(1:nmob).’;

[xym,xyv]=mobmove(xym,xyv,10,5,10,rhombvec);

plot(xym, ‘b*’);

This gives the mobile an initial position and an initial velocity. By using mobmove again the
mobile can be moved a little bit more.

 We Created the following commands to check this:

[xym,xyv]=mobmove(xym,xyv,10,5,30,rhombvec);

hold on;

plot(xym, ‘r*’);

[xym,xyv]=mobmove(xym,xyv,10,5,30,rhombvec);

plot(xym, ‘g*’);

21
WIRELESS LAB REPORT

hold off;

This show, the mobile should have moved a little bit each time when we call the mobmove.

a. Input parameters to Mobmove argument :

 xym and xyv are the mobile position and mobile velocity.
 The next two parameters are the average speed (m/s) and average acceleration (m/s2).
These parameters are used when the mobile velocity is updated.
 The fifth parameter is the time step in seconds. The mobile moves a distance that is
equal to the mobile velocity multiplied by the time step.
 The last argument is the rhombvec that contains the two vectors that span the area
containing the system. Mobmove needs to know the system area for two purposes:
 First, it should be able to spread the mobiles evenly over the service area
 Second, when a mobile already has been given the position and is moving around in the
service area.

b. Output parameters to Mobmove argument :

The return vector contains the number of mobiles (m), the mobile position (xym) and the
velocity of the mobile (xyv).

 Now, develop part of the simulation program that creates a number of mobiles and puts
them into the system. In many simulation program the number of mobiles is a random
quantity. Here, let assume that the program create a specific number of mobiles.
 we Added the following codes on the base station code before the plot part
 To Create new mobiles

par.vmean=10;

par.amean=5;

par.dt=10;

nmob=10;

xym=nans(nmob,1);

22
WIRELESS LAB REPORT

xyv=nans(nmob,1);

m=(1:nmob).’;

[xym,xyv]=mobmove(xym,xyv,par.vmean,par.amean,par.dt,rhombvec);

 And then we added the following code after the plot part

hold on;

plot(xym,’b*’);

hold off;

 Full code to create the mobiles with the previous base stations
 To Define the cellular parameters

par.cellradius=1000;

par.km=1;

par.lm=2;

par.kn=1;

par.ln=0;

par.sps=1;

par.amean = 1;

par.vmean = 15;

par.dt = 1;

 To Create the base stations

[xyb,fib,rhombvec]=crecells(par.cellradius, par.sps, par.km, par.lm, par.kn, par.ln);

23
WIRELESS LAB REPORT

 To Create the mobiles

nmob=100;

xym=nans(nmob,1);

xyv=nans(nmob,1);

m=(1:nmob).';

[xym,xyv]=mobmove(xym,xyv,par.vmean,par.amean,par.dt,rhombvec);

 To Plot the system

figure(1);

clf

C=[0.1, 0.6,0.3, 0.8, 0.4, 0.2,0.9]; % shows the colour of the cell

plothex(xyb,fib, C);

hold on;

plot(xym,'b.');

hold off;

24

You might also like