WC LAB Manual Final
WC LAB Manual Final
LIST OF EXPERIMENTS
1
2
Ex. No: 1 Modeling of wireless communication systems using MATLAB
Date: (Two ray channel and Okumura –Hata model)
Aim:
To write a MATLAB program for modeling of wireless communication systems (Two
ray channel and Okumura – Hata model).
Apparatus Required:
Hardware: Personal Computer
Software: MATLAB 2022b
Theory:
Two- ray model:
The two-rays ground-reflection model is a multipath radio propagation model which
predicts the path losses between a transmitting antenna and a receiving antenna when they are
in line of sight (LOS). Generally, the two antenna each have different height. The received
signal having two components, the LOS component and the reflection component formed
predominantly by a single ground reflected wave.
Okumura Model:
Okumura`s model is one of the most widely used models for signal prediction in urban
areas. This model is applicable for frequencies in the range 150 MHz to 1920 MHz (although
it is typically extrapolated up to 3000 MHz) and distances of 1 km to 100 km. It can be used
for base station antenna heights ranging from 30 m to 1000 m. Okumura developed a set of
curves giving the median attenuation relative to free space (Amu), in an urban area over a
quasi-smooth terrain with a base station effective antenna height (hte) of 200 m and a mobile
antenna height (hre) of 3 m. These curves were developed from extensive measurements using
vertical omni-directional antennas at both the base and mobile, and are plotted as a function of
frequency in the range 100 MHz to 1920 MHz and as a function of distance from the base
station in the range 1 km to 100 km. To determine path loss using Okumura`s model, the free
space path loss between the points of interest is first determined, and then the value of Amu(f,
d) (as read from the curves) is added to it along with correction factors to account for the type
of terrain. The model can be expressed as
L50(dB) = LF+ Amu(f, d)-G(te)- G(re) - GAREA
where L50 is the 50th percentile (i.e., median) value of propagation path loss, LF is the
free space propagation loss, Amu is the median attenuation relative to free space, G(hte) is the
base station antenna height gain factor, G(hre) is the mobile antenna height gain factor, and
GAREA is the gain due to the type of environment.
Hata Model:
The Hata model [Hat90] is an empirical formulation of the graphical path loss data
provided by Okumura, and is valid from 150 MHz to 1500 MHz. Hata presented the urban area
propagation loss as a standard formula and supplied correction equations for application to
other situations. The standard formula for median path loss in urban areas is given by
L50(urban)(dB) = 69.55 + 26.16logfc -13.82loghte-a(hre) + (44.9 - 6.55loghte)logd where fc
is the frequency (in MHz) from 150 MHz to 1500 MHz, hte is the effective transmitter (base
station) antenna height (in meters) ranging from 30 m to 200 m,hre is the effective receiver
(mobile) antenna height (in meters) ranging from 1 m to 10 m, d is the T-R separation distance
(in km), and a(hre) is the correction factor for effective mobile antenna height which is a
function of the size of the coverage area
3
4
Pre-lab Questions:
1. What is Okumura and Hata model in wireless communication?
2. What is channel modelling in wireless communication?
3. What is two ray model in wireless communication?
4. Is the Hata model used for signal strength prediction?
5. Which is the major disadvantage of Okumura model?
Procedure:
Step 1: Start the program.
Step 2: Get the inputs for gain, height and distance
Step 3: Respective model will be formulated and run according to the values given.
Step 4: Output is generated.
Step 5: Terminate the process.
Program:
Two – ray model:
c = physconst('LightSpeed');
fs = 1e6;
pw = 10e-6;
pri = 2*pw;
PRF = 1/pri;
fc = 100e6;
lambda = c/fc;
waveform = phased.RectangularWaveform('SampleRate',fs,'PulseWidth',pw,...
'PRF',PRF,'OutputFormat','Pulses','NumPulses',2);
wav = waveform();
n = size(wav,1);
figure;
plot((0:(n-1)),real(wav),'b.-');
xlabel('Time (samples)')
ylabel('Waveform magnitude')
pos1 = [1000;0;10000];
pos2 = [0;100;100];
vel1 = [0;0;0];
vel2 = [0;0;0];
channel = twoRayChannel('SampleRate',fs,...
'GroundReflectionCoefficient',.9,'OperatingFrequency',fc,...
'CombinedRaysOutput',false);
prop_signal = channel([wav,wav],pos1,pos2,vel1,vel2);
n = size(prop_signal,1);
delay = 0:(n-1);
plot(delay,abs(prop_signal(:,1)),'g')
hold on
plot(delay,abs(prop_signal(:,2)),'r')
plot(delay,abs(prop_signal(:,1) + prop_signal(:,2)),'b')
hold off
legend('Line-of-sight','Reflected','Combined','Location','NorthWest')
xlabel('Delay (samples)')
ylabel('Signal Magnitude')
5
6
Okumura model:
clc;
clear all;
close all;
Hte=input('Enter Base station Antenna Height (hte): ');
Hre=input('Enter Mobile Station Antenna Height (hre): ');
d =input('Enter distance from base station : ');
f=input('Enter the frequency: ');
Amu = input('Enter the Median attenuation value in dB : ');
Kcor = input('Enter the Correction factor value in dB : ');
for i=1:length(f)
Lfsl = 20*log((4*pi*d)/((3*10^8)/((f(i))*10^6)));
Ghte = 20*log(Hte/200);
if(Hre>3)
Ghre = 20*log(Hre/3);
else
Ghre = 10*log(Hre/3);
end
L(i) = Lfsl+Amu(i)-Ghte-Ghre-Kcor(i);
end
disp(L)
figure(1)
plot(f,L);
title('Frequency vs Loss (dB) for open area for Okumura Model');
xlabel('Frequency(MHz)');
ylabel('Propagation Path loss(dB)');
grid on;
Hata model
clc;
clear all;
close all;
Hte=input('Enter Base station Antenna Height (hte)');
Hre=input('Enter Mobile Station Antenna Height (hre)');
d =input('Enter distance from base station');
f=input('Enter the frequency: ');
for i=1:length(f)
CH = 0.8 +((1.1*log( f(i)))-0.7)*Hre - 1.56*log(f(i));
LU(i)=69.55+26.16*log (f(i))-13.82*log(Hte) -CH+(44.9-6.55*log(Hte))*log(d);
end
figure(1)
plot(f,LU)
title('Frequency vs Loss (dB) for small city for Hata Model');
xlabel('Frequency (MHz)');
ylabel('Propagation Path loss(dB)');
grid on;
[200 300 400 500 600 700 800 900 1000 1100]
7
8
Post-lab Questions:
1. What are the features of Okumura propagation model?
2. What are the advantages of Hata model?
3. How many types of propagation models are there?
4. How propagation path loss is calculated by Hata model?
5. What is the correction factor in Okumura model?
9
10
Result:
Thus the wireless communication system for Two-ray model, Hata model and
Okumara model has been performed using MATLAB successfully.
11
12
Ex. No: 2 Modeling and simulation of Multipath fading channel
Date:
Aim:
To write a MATLAB program for modeling and simulation of multipath fading.
channel.
Apparatus Required:
Hardware: Personal Computer
Software: MATLAB 2022b
Theory:
In wireless communication, fading is a phenomenon in which the strength and quality
of a radio signal fluctuate over time and distance. Fading is caused by a variety of factors,
including multipath propagation, atmospheric conditions, and the movement of objects in the
transmission path. Fading can have a significant impact on the performance of wireless
communication systems, particularly those that operate in high-frequency bands.
Small Scale Fading
• Small-scale fading is a common issue in wireless communication.
• It happens when a signal is transmitted from a transmitter to a receiver and it
experiences multiple signal paths due to reflection, diffraction, and scattering from
objects in the environment.
• These signal paths can cause interference and distortion to the signal, resulting in
fluctuations of the signal strength at the receiver.
Multipath delay spread
• Multipath delay spread is a type of small-scale fading that occurs when a transmitted
signal takes multiple paths to reach the receiver.
• The different components of the signal can arrive at the receiver at different times,
causing interference and rapid variations in signal amplitude and phase.
• Multipath delay spread can cause Inter-Symbol Interference (ISI), where symbols
in the transmitted signal overlap and interfere with each other, leading to errors in
the received signal.
Doppler Spread
• Doppler spread is a type of small-scale fading that occurs when there is relative
motion between the transmitter and the receiver.
• The relative motion causes a shift in the frequency of the transmitted signal, known
as the Doppler shift.
Large Scale Fading
• Large-scale fading is a phenomenon that occurs in wireless communication when
the signal strength decreases over long distances.
• Large-scale fading is called “large-scale” because the variations occur over long
distances, typically several kilometres.
• Unlike small-scale fading, which affects individual symbols or bits, large-scale
fading affects the entire signal.
Shadowing
• Shadowing is a type of large-scale fading that occurs due to the presence of
obstacles or obstructions in the path of the signal.
• Shadowing causes the signal power to vary as the receiver moves in the
environment
13
14
Pre-lab Questions:
1. What is meant by channel fading?
2. What is multipath effect in wireless channel?
3. What is fading channel capacity?
4. What is meant by Rayleigh fading?
5. What are the disadvantages of multipath?
Procedure:
Step 1: Start the program.
Step 2: Create a channel System object that describes the channel
Step 3: Adjust properties of the System object, as needed to model your channel.
Step 4: Call the channel System object like a function to apply the channel model, which
generates random discrete path gains and filters the input signal.
Step 5: Terminate the process.
Program:
clear
f_c=1e3;%carrier frequency(no modulation)
time_1 = (linspace (0, 10, 1000));%time
signal_in = sin (2 * pi *f_c* time_1);%sine wave
plot (time_1, signal_in, 'b');grid on;%blue=signal_in
xlabel('time');ylabel('amplitude');
title('Rayleigh fading channel with two path sine wave input')
hold on
for ii = 1:10%# iterations
tau=round(50*rand(1,1)+1);% variable delay(phase shift)
g1=1;%fixed gain
g2=round(.5*rand(1,1)+1);%variable gain or attenuation
signal_out=g1*signal_in + g2*[zeros(1,tau) signal_in(1:end-tau)];
plot (time_1,(signal_out),'r')%red=signal_out
pause (2)%~ seconds
end
hold off
Post-lab Questions:
1. Why is Rayleigh fading channel used?
2. Which modulation is better in Rayleigh channel and why?
3. What is the difference between Rayleigh and Rician distribution?
4. How do you reduce multipath effects?
5. How do you calculate multipath fading?
15
16
17
18
Result:
Thus the multipath path fading was modelled and simulated using MATLAB
successfully.
19
20
Ex. No: 3 Design, analyze and test Wireless standards and evaluate the
Date: performance measurements such as BER, PER, BLER,
throughput, capacity, ACLR, EVM for 4G and 5G using MATLAB.
Aim:
To write a MATLAB program for Design, analyze and test Wireless standards and
evaluate the performance measurements such as BER, PER, BLER, throughput, capacity,
ACLR, EVM for 4G and 5G Apparatus
Required:
Hardware: Personal Computer
Software: MATLAB 2022b
Theory:
The bit error rate (BER) is the number of bit errors per unit time. The bit error ratio (also BER)
is the number of bit errors divided by the total number of transferred bits during a studied time
interval. Bit error ratio is a unitless performance measure, often expressed as a percentage.
Throughput refers to the amount of data flowing down a network at any given unit of time.
While bandwidth specifies the net achievable link speed, throughput is the actual link speed as
seen in real time scenarios. In practice, throughput is less than the bandwidth.
The channel capacity, C, is defined to be the maximum rate at which information can be
transmitted through a channel. The fundamental theorem of information theory says that at any
rate below channel capacity, an error control code can be designed whose probability of error
is arbitrarily small. Block error rate (BLER) — the ratio of the number of transport blocks
received in error to the total number of blocks transmitted over a certain number of frames.
This measurement is one of the simplest metrics used to measure the physical layer
performance of a device and is performed after channel de-interleaving and decoding by
evaluating the cyclic redundancy check (CRC) on each transport block received.
BLER closely reflects on the RF channel conditions and the level of interference. For a given
modulation depth, the cleaner the radio channel or higher the SNR, the less likely the transport
block being received in error. That indicates a lower BLER. The inverse also stands true, where
for a given SNR, the higher the modulation depth, the higher the possibility of error due to
interference, thereby magnifying the BLER. Bearing that in mind, BLER proves to be one of
the key measures of:
• Receiver sensitivity
• Download throughput
• In-sync and out-of-sync indication during radio link monitoring (RLM)
Error vector magnitude (EVM) is a popular system-level performance metric that is defined in
many communication standards, such as wireless local area networks (WLAN 802.11), mobile
communications (4G LTE, 5G), and many more, as a compliance test. Beyond this, it is an
extremely useful system-level metric to quantify the combined impact of all the potential
impairments in a system through a single and easy to understand value. EVM is a simple metric
21
22
to quantify the combination of all signal impairments in a system. It is frequently defined for
devices that use digital modulation, which can be represented through a plot of in-phase (I) and
quadrature (Q) vectors also known as a constellation diagram,
The ACLR is the ratio of the filtered mean power centered on the assigned channel frequency
to the filtered mean power centered on an adjacent channel frequency.
Pre-lab Questions:
1. How is the capacity of communication media measured?
2. What are the requirements for 5G mobile?
3. What are the two biggest advantages of 5G?
4. What is SNR and BER?
5. What factors affect the bit error rate?
Procedure:
Step 1: Start the program.
Step 2: Create a channel with modulation signal and required input values
Step 3: Assign the users and the frequency usage of the signal.
Step 4: The performance metrics will be calculated according to the formulas given in the
program and the values will be displayed.
Step 5: Terminate the process.
Program:
clc;
clear all;
close all;
% Parameters
numBits = 1e6; % Number of bits to transmit
modulation = 16; % Modulation scheme
codingRate = 0.5; % Channel coding rate
SNRdB = 0:2:20; % Signal-to-Noise Ratio (dB) range
numUsers = 10; % Number of simultaneous users for capacity calculation
desiredSignalFrequency = 2e9; % Desired signal frequency in Hz
adjacentChannelFrequency = 2.5e9; % Adjacent channel frequency in Hz
sampleRate = 10e6; % Sample rate in Hz
% Generate random data bits
dataBits = randi([0 1], 1, numBits);
% Modulation
modulatedSignal = qammod(dataBits, modulation);
% Add AWGN noise
for snrIdx = 1:length(SNRdB)
snr = 10^(SNRdB(snrIdx)/10);
receivedSignal = awgn(modulatedSignal, snr, 'measured');
% Demodulation
demodulatedBits = qamdemod(receivedSignal, 32);
% BER calculation
ber(snrIdx) = sum(demodulatedBits ~= dataBits) / numBits;
% PER calculation
numErrors = sum(demodulatedBits ~= dataBits);
per(snrIdx) = numErrors / length(find(diff([0, dataBits]) == 1));
end
% BLER calculation
%bler = per.*(diff([0, dataBits]) == 1);
23
24
% Throughput calculation
%throughput = (1 - bler) * numBits / numBits;
% Capacity calculation
capacity = zeros(size(SNRdB));
for snrIdx = 1:length(SNRdB)
snr = 10^(SNRdB(snrIdx)/10);
capacity(snrIdx) = numUsers * log2(1 + snr);
end
% ACLR measurement
desiredSignal = cos(2*pi*desiredSignalFrequency*(0:numBits-1)/sampleRate);
adjacentSignal = cos(2*pi*adjacentChannelFrequency*(0:numBits-1)/sampleRate);
receivedSignal = desiredSignal + adjacentSignal;
% Measure ACLR
%psd = periodogram(receivedSignal, rectwin(length(receivedSignal)),
length(receivedSignal)*2);
%desiredPower = bandpower(psd, sampleRate, [desiredSignalFrequency-1e6
desiredSignalFrequency+1e6]);
%adjacentPower = bandpower(psd, sampleRate, [adjacentChannelFrequency-1e6
adjacentChannelFrequency+1e6]);
%aclr = desiredPower / adjacentPower;
% EVM measurement
referenceSignal = cos(2*pi*desiredSignalFrequency*(0:numBits-1)/sampleRate);
evm = sqrt(mean(abs(receivedSignal - referenceSignal).^2)) /
sqrt(mean(abs(referenceSignal).^2));
% Display results
disp('BER:');
disp(ber);
disp('PER:');
disp(per);
%disp('BLER:');
%disp(bler);
%disp('Throughput:');
%disp(throughput);
disp('Capacity:');
disp(capacity);
%disp('ACLR:');
%disp(aclr);
disp('EVM:');
disp(evm);
Post-lab Questions:
1. Why do BPSK and QPSK have the same BER?
2. What is the difference between Ber and BLER?
3. What is the adjacent channel leakage ratio ACLR in RF systems?
4. How do you solve ACLR problems?
5. What is the difference between output and throughput?
25
26
Result:
Thus the performance measurements such as BER, PER, BLER, throughput,
capacity, ACLR, EVM for 4G and 5G has been simulated using MATLAB successfully.
27
28
Ex. No: 4 Modulation: Spread Spectrum – DSSS Modulation & Demodulation
Date:
Aim:
To write a MATLAB program to perform the Direct Sequence Spread Spectrum (DSSS) –
Modulation and Demodulation.
Apparatus Required:
Hardware: Personal Computer
Software: MATLAB 2022b
Theory:
Direct-sequence spread spectrum (DSSS) is a spread-spectrum modulation technique
primarily used to reduce overall signal interference. The direct-sequence modulation makes the
transmitted signal wider in bandwidth than the information bandwidth. After the despreading or
removal of the direct-sequence modulation in the receiver, the information bandwidth is restored,
while the unintentional and intentional interference is substantially reduced.
Direct-sequence spread-spectrum transmissions multiply the data being transmitted by a
pseudorandom spreading sequence that has a much higher bit rate than the original data rate. The
resulting transmitted signal resembles bandlimited white noise, like an audio recording of "static".
However, this noise-like signal is used to exactly reconstruct the original data at the receiving end,
by multiplying it by the same spreading sequence (because 1 × 1 = 1, and −1 × −1 = 1). This process,
known as despreading, is mathematically a correlation of the transmitted spreading sequence with the
spreading sequence that the receiver already knows the transmitter is using. After the despreading,
the signal-to-noise ratio is approximately increased by the spreading factor, which is the ratio of the
spreading-sequence rate to the data rate.
While a transmitted DSSS signal occupies a much wider bandwidth than a simple modulation
of the original signal would require, its frequency spectrum can be somewhat restricted for spectrum
economy by a conventional analog bandpass filter to give a roughly bell-shaped envelope centered
on the carrier frequency. In contrast, frequency-hopping spread spectrum pseudorandomly retunes
the carrier and requires a uniform frequency response since any bandwidth shaping would cause
amplitude modulation of the signal by the hopping code.
If an undesired transmitter transmits on the same channel but with a different spreading
sequence (or no sequence at all), the despreading process reduces the power of that signal. This effect
is the basis for the code-division multiple access (CDMA) property of DSSS, which allows multiple
transmitters to share the same channel within the limits of the cross-correlation properties of their
spreading sequences.
Pre-lab Questions:
1. What is difference between FHSS and DSSS?
2. Why is the DSSS signal so large?
3. What is the spreading ratio of DSSS?
4. What is the spreading factor of DSSS?
5. What are the channels of DSSS?
29
30
Procedure:
Step 1: Start the program.
Step 2: Generate the input sequence and Pseudorandon sequence.
Step 3: Perform the direct sequence spreading, then modulate the signal and transmit.
Step 4: Perform despreading at the receiver and observe the sequence.
Step 5: End the program.
Program:
clc;
clear all;
close all;
% Generating the bit pattern with each bit 20 samples long
b=round(rand(1,30));
pattern=[];
for k=1:30
if b(1,k)==0
sig=-ones(1,20);
else
sig=ones(1,20);
end
pattern=[pattern sig];
end
subplot(4,1,1)
plot(pattern);
axis([-1 620 -1.5 1.5]);
title('Original Bit Sequence');
% Generating the pseudo random bit pattern for spreading
d=round(rand(1,120));
pn_seq=[];
carrier=[];
t=[0:2*pi/4:2*pi]; % Creating 5 samples for one cosine
for k=1:120
if d(1,k)==0
sig=-ones(1,5);
else
sig=ones(1,5);
end
c=cos(t);
carrier=[carrier c];
pn_seq=[pn_seq sig];
end
% Spreading of sequence
spreaded_sig=pattern.*pn_seq;
subplot(4,1,2)
plot(spreaded_sig)
axis([-1 620 -1.5 1.5]);
31
32
title('Spreaded signal');
% BPSK Modulation of the spreaded signal
bpsk_sig=spreaded_sig.*carrier; % Modulating the signal
subplot(4,1,3);
plot(bpsk_sig)
axis([-1 620 -1.5 1.5]);
title('BPSK Modulated Signal');
%Plotting the FFT of DSSS signal
y=abs(fft(xcorr(bpsk_sig)));
subplot(4,1,4)
plot(y/max(y))
xlabel('Frequency')
ylabel('PSD')
%Demodulation and Despreading of Received Signal
figure
rxsig=bpsk_sig.*carrier;
demod_sig=[];
for i=1:600
if rxsig(i)>=0
rxs =1;
else
rxs =-1;
end
demod_sig=[demod_sig rxs];
end
subplot(3,1,1)
plot(demod_sig)
axis([-1 620 -1.5 1.5]);
title('Demodulated Signal')
despread_sig=demod_sig.*pn_seq;
subplot(3,1,2)
plot(despread_sig)
axis([-1 620 -1.5 1.5]);
title('Despreaded data')
Post-lab Questions:
1. Give the speed of DSSS?
2. How to share the bandwidth in DSSS?
3. How to detect the DSSS signals?
4. How does the DSSS reduce interference?
5. Give the high rate of DSSS.
33
34
Result:
Thus the DSSS – Modulation and demodulation has been performed using MATLAB
successfully.
35
36
Ex .No: 5 Wireless Channel Equalization: Zero-Forcing Equalizer (ZFE), MMSE
Equalizer (MMSEE), Adaptive Equalizer (ADE), Decision Feedback
Equalizer (DFE)
Date:
Aim:
To write a MATLAB program to simulate various equalization techniques such as Zero-Forcing
Equalizer (ZFE), MMSE Equalizer (MMSEE), Adaptive Equalizer (ADE), Decision Feedback
Equalizer (DFE).
Apparatus Required:
Hardware: Personal Computer
Software: MATLAB 2022b
Theory:
In a multipath fading scattering environment, the receiver typically detects several constantly
changing, delayed versions of the transmitted signal. These time-dispersive channels cause
intersymbol interference (ISI) that occurs when symbols received from multiple paths are delayed
and overlap in time. ISI causes high error rates because the symbols from multiple received paths
interfere with each other and become indistinguishable by the receiver.
Equalizers attempt to mitigate ISI and improve the receiver performance. Equalizer structures
are filters that attempt to match the propagation channel response. For time-varying propagation
channels, adapting the equalization filter tap weights so that they maintain a match to the channel
over time improves the error rate performance.
37
38
Linear and decision-feedback filter equalizer structures adapt tap weights by using the LMS, RLS, or
CMA adaptive algorithm. When using these equalizer structures, the number of samples per symbol
determines whether symbols are processed using whole or fractional symbol spacing.
• When using LMS and RLS adaptive algorithms, the equalizer begins operating in tap weights
training mode. Configure the equalizer to operate adaptively in decision-directed mode or
without further adjustment of taps after training is completed.
• When using the CMA adaptive algorithm, the equalizer has no training mode. You can
configure the equalizer to operate adaptively in decision-directed mode or in nonadaptive
mode.
• Maximum-Likelihood Sequence Estimation (MLSE) equalizers use the Viterbi algorithm.
The MLSE equalization structure provides the optimal match to the received symbols but it
requires an accurate channel estimate and is the most computationally complex structure.
The computational complexity of each equalization structure grows with the length of the channel
time dispersion.
Pre-lab Questions:
1. State the need for equalization.
2. Why is an adaptive equalizer required?
3. Distinguish between linear and Non-linear equalization.
4. List out the factors that influence the performance of adaptive equalization algorithms.
5. What are the differences between zero forcing and mean squared error equalizer?
Procedure:
Step 1: Start the program.
Step 2: Give the length of input sequence, no. of taps of filter in the equalizer.
Step 3: Convolve the input sequence with the impulse response of the channel
Step 4: Add the Additive White Gaussian Noise in the channel.
Step 5: Equalize the received signal with the respective equalizer.
Step 6: Observe the output sequence and bit error rate.
Step 7: End the program.
Program:
ZERO-FORCING EQUALIZER:
clc;
clear all;
close all;
N=6;
x=(-1).^(floor(2*rand(1,N)))
g=[0.16, 0.45];
Y=conv(g,x);
SNRdB=100;
r=awgn(Y,SNRdB);
Xh = ZF(g,r);
Xh(find(Xh>0))=1;
Xh(find(Xh<0))=-1;
Xh
39
40
function Xh = ZF(h,r)
gD=tf(h,1);
f=1/gD;
[num,den]=tfdata(f,'v');
Xh=filter(num,den,r);
Xh=Xh(2:end);
end
MMSE EQUALIZER:
clc;
clear all;
close all;
N=6;
x=(-1).^(floor(2*rand(1,N)))
g=[0.16 0.45];
Y=conv(g,x);
SNRdB=10;
r=awgn(Y,SNRdB);
N0=1/10^(SNRdB/11);
Xh = LMMSE(g,r,N0,N );
Xh(find(Xh>0))=1;
Xh(find(Xh<0))=-1;
Xh
function Xh = LMMSE(g,r,N0,N )
gDconjTimeInv=filt(conj(fliplr(g)),1);
gD=filt(g,1);
f=gDconjTimeInv/(gD*gDconjTimeInv+N0);
[num,den]=tfdata(f,'v');
Xh=filter(num,den,r);
Xh=Xh(1:N);
end
41
42
k=10*N;
while k>0
e = d - h.*x;
temp = h;
h=temp + mu*e .* x;
k=k-1;
end
yd = h .* x;
subplot(2,2,1), plot(t,d);
title('Input Signal'),ylim([-1.5 1.5]);grid;
subplot(2,2,2), plot(t,x);
title('Input Signal with Noise'),grid;
subplot(2,2,3), plot(t,e);grid
title('Error'),
subplot(2,2,4), plot(t,yd);grid;
title('Adaptive Equalized output');ylim([-1.5 1.5]);
43
44
Post-lab Questions:
1. Find whether the Tx and Rx data are same for the input bits [1 1 0 1 0 0 1 0] using ZF
algorithm.
2. Check whether you can able to transmit and receive the sequence [0 1 1 0 0 0 1 1] using Zero
Forcing equalizer.
3. Determine the output of Adaptive equalizer for the sequence length of 50 and adaptation
constant of 0.2.
4. Find whether the Tx and Rx data are same for the input bits [1 1 0 1 0 0 1 0] using MMSE
algorithm.
5. Determine the output of and equalizer with LMS algorithm for the sequence length of 75
and adaptation constant of 0.6.
Result:
Thus the ZF equalizer, Adaptive equalizer, MMSE equalizer and DF equalizer has been
simulated using MATLAB successfully.
45
46
Ex .No:06 Modeling And Simulation of TDMA, FDMA AND CDMA For
Wireless Communication
Date:
Aim:
To write a MATLAB program to model and simulate TDMA, FDMA and CDMA for Wireless
Communication.
Apparatus Required:
Hardware: Personal Computer
Software: MATLAB 2022b
Theory:
In wireless communication systems, it is often desirable to allow the subscriber to send
information simultaneously from the mobile station to the base station while receiving information
from the base station to the mobile station.
A cellular system divides any given area into cells where a mobile unit in each cell
communicates with a base station. The main aim in the cellular system design is to be able to increase
the capacity of the channel, i.e., to handle as many calls as possible in a given bandwidth with a
sufficient level of quality of service.
There are several different ways to allow access to the channel. These includes mainly the
following −
• Frequency division multiple-access (FDMA)
• Time division multiple-access (TDMA)
• Code division multiple-access (CDMA)
47
48
• TDMA has an advantage that is possible to allocate different numbers of time slots per frame
to different users.
• Bandwidth can be supplied on demand to different users by concatenating or reassigning time
slot based on priority.
Procedure:
Step 1: Start the program.
Step 2: Give the values of samples, nodes, slots and guard band.
Step 3: Generate the respective multiple access techniques.
Step 4: Observe the output waveform.
Step 5: End the program.
Program:
FREQUENCY DIVISION MULTIPLE ACCESS (FDMA)
clc;
clear all
close all
samples=1000;
nos=4;
mfreq=[30 40 50 60];
cfreq=[300 600 900 1200];
freqdev=10;
t=linspace(0,1000,samples);
parfor i=1:nos
m(i,:)=sin(2*pi*mfreq(1,i)*t)+2*sin(pi*8*t);
end
parfor i=1:nos
y(i,:)=fmmod(m(i,:),cfreq(1,i),10*cfreq(1,i),freqdev);
end
49
50
ch_op=awgn(sum(y),0,'measured');
parfor i=1:nos
z(i,:)=fmdemod(y(i,:),cfreq(1,i),10*cfreq(1,i),freqdev);
end
C = {'k','b','r','g','y',[.5 .6 .7],[.8 .2 .6],[.3 .2 .2]}; % Cell array of colors.
for i=1:nos
figure (1)
hold on
plot(y(i,:),'color',C{i});
xlabel('time index'); ylabel('amplitude');
title('Signal from different users combined in the channel');
figure
subplot(3,1,1)
plot(m(i,:))
xlabel('time index'); ylabel('amplitude'); title('modulating Signal from user');
subplot(3,1,2)
plot(y(i,:),'color',C{i});
xlabel('time index'); ylabel('amplitude'); title('modulated Signal from user');
subplot(3,1,3)
plot(z(i,:),'color',C{i});
xlabel('time index'); ylabel('amplitude'); title('demodulated Signal from user at the base station');
end
figure
plot(ch_op)
xlabel('time index'); ylabel('amplitude'); title('Signal after passing through the channel');
51
52
data=[1 0 0 1 1 0 1 1];
figure('Name','Message BPSK Modulation','NumberTitle','off')
subplot(2,1,1);
plot(rectpulse(data,100));
axis([0 length(rectpulse(data,100)) -0.2 1.2]);
title('Message Signal');
xlabel('n');
ylabel('x(n)');
grid on;
data(data(:)==0)=-1;
length_data=length(data);
fc1=10;
eb=2;
tb=1;
T=1;
msg=rectpulse(data,100);
N=length_data;
Tb = 0.0001;
nb=100;
br = 1/Tb;
Fc = br*10;
t2 = Tb/nb:Tb/nb:Tb;
t1=0.01:0.01:length_data;
bpskmod=sqrt(2/T)*cos(2*pi*fc1*t1);
bpsk_data=msg.*bpskmod;
subplot(2,1,2)
plot(bpsk_data)
title(' BPSK signal');
xlabel('Time Period(t)');
ylabel('x(t)');
axis([0 100*length_data -2 2]);
grid on;
sr=[1 -1 1 -1];
pn1=[];
for i=1:length_data
for j=1:10
pn1=[pn1 sr(4)];
if sr (4)==sr(3)
temp=-1;
else temp=1;
end
sr(4)=sr(3);
sr(3)=sr(2);
53
54
sr(2)=sr(1);
sr(1)=temp;
end
end
figure('Name','PN Generation and CDMA','NumberTitle','off');
subplot(2,1,1);
stem(pn1);
axis([0,length(pn1),-1.2,1.2])
title('PN sequence for data')
xlabel('n');
ylabel('x(n)');
grid on;
pnupsampled1=[];
len_pn1=length(pn1);
for i=1:len_pn1
for j=0.1:0.1:tb
pnupsampled1=[pnupsampled1 pn1(i)];
end
end
length_pnupsampled1=length(pnupsampled1);
subplot(2,1,2);
sigtx1=bpsk_data.*pnupsampled1;
plot(sigtx1);
title('CDMA Signal');
xlabel('Time Period(t)');
ylabel('x(t)');
sigtonoise=20;
composite_signal=awgn(sigtx1,sigtonoise);
figure('Name','CDMA Reciever','NumberTitle','off')
subplot(2,1,1);
plot(sigtx1);
title('Tx Signal');
xlabel('Time Period(t)');
ylabel('x(t)');
grid on;
%Rx
rx=composite_signal.*pnupsampled1;
subplot(2,1,2);
plot(rx);
title('CDMA Demodulated signal');
xlabel('Time Period(t)');
ylabel('x(t)');
grid on;
55
56
Post-lab Questions:
1. Generate the FDMA sequence for 3 users.
2. Generate the FDMA sequence for 8 users.
3. Generate the TDMA for 6 nodes.
4. Generate the CDMA signal for the data = [1 0 0 1 1 0 1 1].
5. Generate the CDMA signal for the data = [1 0 1 1 0 1 0 1].
Result:
Thus the TDMA, FDMA and CDMA has been modeled and simulated using MATLAB
successfully.
57
58
Ex. No: 7 MINIMUM SHIFT KEYING – MODULATION AND
DEMODULATION
Date:
Aim:
To write a MATLAB program to perform the MSK Modulation and Demodulation.
Apparatus Required:
Hardware: Personal Computer
Software: MATLAB 2022b
Theory:
Minimum Shift Keying (MSK) is a type of continuous-phase frequency-shift keying. Similar
to OQPSK, MSK is encoded with bits alternating between quadrature components, with the Q
component delayed by half the symbol period.
However, instead of square pulses as OQPSK uses, MSK encodes each bit as a half sinusoid.
This results in a constant-modulus signal (constant envelope signal), which reduces problems caused
by non-linear distortion. In addition to being viewed as related to OQPSK, MSK can also be viewed
as a continuous-phase frequency-shift keyed (CPFSK) signal with a frequency separation of one-half
the bit rate.
In MSK the difference between the higher and lower frequency is identical to half the bit rate.
Consequently, the waveforms used to represent a ‘0’ and a ‘1’ bit differ by exactly half a carrier
period. Thus, the maximum frequency deviation is δ = 0.5 fm where fm is the maximum modulating
frequency. As a result, the modulation index m is 0.5. This is the smallest FSK modulation index that
can be chosen such that the waveforms for 0 and 1 are orthogonal. A variant of MSK called Gaussian
minimum-shift keying (GMSK) is used in the GSM mobile phone standard.
Pre-lab questions:
1. What is the difference between MSK and FSK?
2. What are the advantages and drawback of MSK?
3. List the applications of MSK.
4. Compare QPSK and MSK.
5. What is Gaussian MSK?
Procedure:
Step 1: Start the MATLAB
Step 2: Generate binary data.
Step 3: MSK modulate the data.
Step 4: Pass the signal through an AWGN channel.
Step 5: Demodulate the MSK signal.
Step 6: Determine the number of bit errors.
Step 7: End the program
59
60
Program:
clc;
clear all;
close all;
%%%Define the number of samples per symbol for the MSK signal%%
nsamp = 16;
%%Initialize the simulation parameters%%
numerrs = 0;
modPhase = zeros(1,2);
demodPhase = zeros(1,2);
demodState = complex(zeros(nsamp,2));
%%%Initialize the simulation parameters.%%%
for iRuns = 1:20
txData = randi([0 1],10,2);
[modSig,modPhase] = mskmod(txData,nsamp,[],modPhase);
rxSig = awgn(modSig,0,'measured');
[rxData,demodPhase,demodState] = mskdemod(rxSig,nsamp,[],demodPhase,demodState);
numerrs = numerrs + biterr(txData,rxData);
end
subplot(2,2,1);
stem(txData);
title('Input data');
subplot(2,2,2);
stem(modSig);
title('MSK Modulated signal');
subplot(2,2,3);
stem(rxSig);
title('Noisy signal from the channel');
subplot(2,2,4);
stem(rxData);
title('Demodulated and decoded data');
%%Display the number of bit errors%%
disp(numerrs)
Postlab Questions:
1. How Very Minimum Shift Keying differs from MSK?
2. Why MSK is called as CPFSK?
3. How to simulate MSK in MATLAB?
4. Generate the MSK for 4 samples per symbol.
5. Generate the MSK for 8 samples per symbol.
61
62
63
64
Result:
Thus the MSK modulation and demodulation has been performed using MATLAB successfully.
65
66
Ex. No: 8 ORTHOGONAL FREQUENCY DIVISION MULTIPLEXING
Date:
Aim:
To write a MATLAB program to perform the OFDM – Modulation and Demodulation.
Apparatus Required:
Hardware: Personal Computer
Software: MATLAB 2022b
Theory:
Orthogonal frequency-division multiplexing is a method of data transmission where a single
information stream is split among several closely spaced narrowband subchannel frequencies instead
of a single Wideband channel frequency. It is mostly used in wireless data transmission but may be
employed in wired and fiber optic communication as well.
In a traditional single-channel modulation scheme, each data bit is sent serially or sequentially
one after another. In OFDM, several bits can be sent in parallel, or at the same time, in separate
substream channels. This enables each substream's data rate to be lower than would be required by a
single stream of similar bandwidth. This makes the system less susceptible to interference and enables
more efficient data bandwidth.
In the traditional stream, each bit might be represented by a 1 nanosecond segment of the
signal, with 0.25 ns spacing between bits, for example. Using OFDM to split the signal across four
component streams lets each bit be represented by 4 ns of the signal with 1 ns spacing between. The
overall data rate is the same, 4 bits every 5 ns, but the signal integrity is higher.
OFDM builds on simpler frequency-division multiplexing (FDM). In FDM, the total data
stream is divided into several subchannels, but the frequencies of the subchannels are spaced farther
apart so they do not overlap or interfere. With OFDM, the subchannel frequencies are close together
and overlapping but are still orthogonal, or separate, in that they are carefully chosen and modulated
so that the interference between the subchannels is canceled out.
Pre-lab questions:
1. What is the basic principle of OFDM?
2. List the benefits of OFDM.
3. Draw the block diagram for OFDM.
4. What is cyclic prefix?
5. What is the difference between OFDM and MIMO?
Procedure:
Step 1: Start the MATLAB
Step 2: Give the input sequence length, FFT length and cyclic prefix length.
Step 3: Modulate the data with QAM.
Step 4: Multiplex the signal with OFDM and pass the signal through an AWGN channel.
Step 5: Demultiplex and demodulate the received signal.
Step 6: End the program
67
68
Program:
clc;
clear all;
close all;
%%---- OFDM Modulation--------%%
M = 16;
nfft = 64;
cplen = [16 32];
nSym = 2;
dataSym = randi([0 M-1],nfft,nSym);
qamSig = qammod(dataSym,M,UnitAveragePower=true);
y1 = ofdmmod(qamSig,nfft,cplen);
figure (1)
subplot(3,1,1)
stem(dataSym);
xlabel('time index'); ylabel('amplitude'); title('input data symbols');
subplot(3,1,2)
plot(qamSig)
xlabel('time index'); ylabel('amplitude'); title('QAM signal');
subplot(3,1,3)
plot(y1)
xlabel('time index'); ylabel('amplitude'); title('OFDM signal');
%%---- OFDM De-Modulation--------%%
x1 = ofdmdemod(y1,nfft,cplen);
rxData = qamdemod(x1,M,UnitAveragePower=true);
figure (2)
subplot(2,1,1)
plot(x1);
xlabel('time index'); ylabel('amplitude'); title('OFDM demodulated signal');
subplot(2,1,2)
stem(rxData)
xlabel('time index'); ylabel('amplitude'); title('Received symbols');
isequal(rxData,dataSym)
Postlab Questions:
1. Why do FFT and IFFT are needed in OFDM?
2. How OFDM is used in MIMO?
3. Generate the OFDM signal with FFT length of 60.
4. Generate the OFDM signal with 8 data symbols and FFT length of 32.
5. Generate the OFDM signal with 32 data symbols and FFT length of 128.
69
70
71
72
Result:
Thus the Orthogonal Frequency Division Multiplexing has been simulated using MATLAB
successfully.
73