WC Lab Manual
WC Lab Manual
AIM:
To simulate Two Ray Channel and Okumura – Hata Model using MATLab.
APPARATUS REQUIRED:
1. Personal Computer
PROCEDURE:
2. Open new file and enter the program and save it.
4. Compile the program and check for any error and debug it.
PROGRAM:
Page 1 of 20
D = 44.9; % Model parameter
X = 6.55; % Model parameter
hb = 30; % Base station height in meters
% Calculate path loss using Okumura-Hata model
PL okumura hata = A + B * log10(distance) + C * log10(frequency/1e6) + D - X *
log10(hb)
% Plotting
figure;
plot(distance, Pr_two_ray, 'b-', 'LineWidth', 2);
hold on;
plot(distance, PL_okumura_hata, 'r--', 'LineWidth', 2);
xlabel ('Distance (m)');
ylabel ('Received Power/Path Loss (dB)');
legend ('Two-ray Channel Model', 'Okumura-Hata Model');
grid on;
OUTPUT WAVEFORM:
Page 2 of 20
EXPERIMENT 2: MODELING AND SIMULATION OF MULTIPATH FADING
CHANNEL
AIM:
APPARATUS REQUIRED:
1. Personal Computer
PROCEDURE:
2. Open new file and enter the program and save it.
4. Compile the program and check for any error and debug it.
PROGRAM:
% Simulation parameters
numSamples = 1000; % Number of samples
numPaths = 3; % Number of multipath paths
fadePower = 0.5; % Fading power
% Generate Rayleigh fading channel coefficients
h = sqrt(fadePower/2)*(randn(numPaths, numSamples) + 1i*randn(numPaths,
numSamples));
% Generate transmitted signal
txSignal = randn(1, numSamples) + 1i*randn(1, numSamples);
% Simulate multipath fading channel
rxSignal = zeros(1, numSamples);
for path = 1:numPaths
rxSignal = rxSignal + h(path, :) .* txSignal;
end
% Plot the transmitted and received signals
t = 1:numSamples;
figure;
subplot(2,1,1);
Page 3 of 20
plot(t,real(txSignal),'b',t,imag(txSignal),'r');
title('transmitted signal');
legend('In-phase','quadrature');
xlabel('time');
ylabel('amplitude');
subplot(2,1,2);
plot(t,real(rxSignal),'b',t,imag(rxSignal),'r');
title('received signal');
legend('In-phase','quadrature');
xlabel('time');
ylabel('amplitude');
OUTPUT WAVEFORM:
Page 4 of 20
EXPERIMENT 3: MODULATION: SPREAD SPECTRUM – DSSS MODULATION
AND DEMODULATION
AIM:
APPARATUS REQUIRED:
1. Personal Computer
PROCEDURE:
2. Open new file and enter the program and save it.
4. Compile the program and check for any error and debug it.
PROGRAM:
clc;
b=[1 0 1 0 1 0 1 0];
ln=length(b);
% Converting bit 0 to -1
for i=1:ln
if b(i)==0
b(i)=-1;
end
end
% Generating the bit sequence with each bit 8 samples long
k=1;
for i=1:ln
for j=1:8
bb(k)=b(i);
j=j+1;
k=k+1;
end
i=i+1;
end
len=length(bb);
Page 5 of 20
subplot(2,1,1);
stairs(bb); %stairs(bb,'linewidth',2);
axis([0 len -2 3]);
title('ORIGINAL BIT SEQUENCE b(t)');
% Generating the pseudo random bit pattern for spreading
pr_sig=round(rand(1,len));
for i=1:len
if pr_sig(i)==0
pr_sig(i)=-1;
end
end
subplot(2,1,2);
stairs(pr_sig); %stairs(pr_sig,'linewidth',2);
axis([0 len -2 3]);
title('PSEUDORANDOM BIT SEQUENCE pr_sig(t)');
% Multiplying bit sequence with Pseudorandom Sequence
for i=1:len
bbs(i)=bb(i).*pr_sig(i);
end
% Modulating the hopped signal
dsss=[];
t=0:1/10:2*pi;
c1=cos(t);
c2=cos(t+pi);
for k=1:len
if bbs(1,k)==-1
dsss=[dsss c1];
else
dsss=[dsss c2];
end
end
figure,
subplot(2,1,1);
stairs(bbs); %stairs(bbs,'linewidth',2);
axis([0 len -2 3]);
title('MULTIPLIER OUTPUT SEQUENCE b(t)*pr_sig(t)');
subplot(2,1,2);
plot(dsss);
Page 6 of 20
OUTPUT WAVEFORM:
-1
-2
0 10 20 30 40 50 60
-1
-2
0 10 20 30 40 50 60
-1
-2
0 10 20 30 40 50 60
DS-SS SIGNAL...
1
0.5
-0.5
-1
0 500 1000 1500 2000 2500 3000 3500 4000 4500
Page 7 of 20
EXPERIMENT 4: DESIGN, ANALYSE AND TEST WIRELESS STANDARDS AND
EVALUATE THE PERFORMANCE MEASUREMENTS SUCH
AS BER, PER, BLER, THROUGHPUT, CAPACITY, ACLR, EVM
FOR 4G AND 5G USING MATLAB
AIM:
To design, analyse and test Wireless Standards and evaluate the performance
measurements such as BER, PER, BLER, Throughput, Capacity, ACLR, EVM for 4G & 5G
using MATLab.
APPARATUS REQUIRED:
1. Personal Computer
PROCEDURE:
2. Open new file and enter the program and save it.
4. Compile the program and check for any error and debug it.
PROGRAM:
clc;
num_bits = 10000;
snr_dB = 0:2:20;
data = randi([0, 1], 1, num_bits);
modulated_data = 2 * data - 1;
ber_simulated = zeros(size(snr_dB));
ber_theoretical = zeros(size(snr_dB));
for i = 1:length(snr_dB)
snr_linear = 10^(snr_dB(i) / 10);
noise_std = sqrt(1 / (2 * snr_linear));
noise = noise_std * randn(1, num_bits);
received_signal = modulated_data + noise;
demodulated_data = sign(received_signal);
Page 8 of 20
num_errors = sum(demodulated_data ~= data);
ber_simulated(i) = num_errors / num_bits;
ber_theoretical(i) = 0.5 * erfc(sqrt(snr_linear));
end
figure;
semilogy(snr_dB,ber_simulated,'bo-','LineWidth',2,
'MarkerSize',8);
hold on;
semilogy(snr_dB,ber_theoretical,'r^-','LineWidth',2, 'MarkerSize', 8);
hold off;
grid on;
legend('Simulated BER', 'Theoretical BER');
xlabel('SNR (dB)');
ylabel('Bit Error Rate (BER)');
title('Bit Error Rate (BER) for BPSK Modulation in AWGN Channel');
OUTPUT WAVEFORM:
Page 9 of 20
PACKET ERROR RATE (PER):
PROGRAM:
clc;
num_packets = 1000;
packet_length = 100;
snr_dB = 10;
snr_linear = 10^(snr_dB / 10);
noise_std = sqrt(1 / (2 * snr_linear));
num_errors = 0;
for i = 1:num_packets
packet_data = randi([0, 1], 1, packet_length);
modulated_data = 2 * packet_data - 1;
noise = noise_std * randn(1, packet_length);
received_signal = modulated_data + noise;
demodulated_data = sign(received_signal);
if any(demodulated_data ~= packet_data)
num_errors = num_errors + 1;
end
end
perr = num_errors / num_packets;
disp(['Number of packets: ' num2str(num_packets)]);
disp(['Packet length: ' num2str(packet_length)]);
disp(['SNR (dB): ' num2str(snr_dB)]);
disp(['Simulated Packet Error Rate (PER): ' num2str(perr)]);
figure;
for i = 1:min(num_packets, 5)
subplot(5, 1, i);
t = 1:packet_length;
plot(t,real(received_signal),'b',t,imag(received_signal), 'r');
title(['Received Signal for Packet ' num2str(i)]);
xlabel('Time');
ylabel('Amplitude');
legend('I-channel', 'Q-channel');
end
OUTPUT:
SNR (dB): 10
Page 10 of 20
OUTPUT WAVEFORM:
PROGRAM:
clc;
num_blocks = 1000;
block_length = 100;
snr_dB = 10;
snr_linear = 10^(snr_dB / 10);
noise_std = sqrt(1 / (2 * snr_linear));
num_errors = 0;
block_error_vector = zeros(1, num_blocks);
for i = 1:num_blocks
block_data = randi([0, 1], 1, block_length);
modulated_data = 2 * block_data - 1;
noise = noise_std * randn(1, block_length);
received_signal = modulated_data + noise;
demodulated_data = sign(received_signal);
if any(demodulated_data ~= block_data)
num_errors = num_errors + 1;
block_error_vector(i) = 1;
end
end
bler = num_errors / num_blocks;
disp(['Number of blocks: ' num2str(num_blocks)]);
Page 11 of 20
disp(['Block length: ' num2str(block_length)]);
disp(['SNR (dB): ' num2str(snr_dB)]);
disp(['Simulated Block Error Rate (BLER): ' num2str(bler)]);
figure;
stem(block_error_vector, 'r', 'LineWidth', 2);
title('Block Error Vector');
xlabel('Block Index');
ylabel('Block Error');
axis([0 num_blocks+1 -0.5 1.5]);
OUTPUT:
SNR (dB): 10
OUTPUT WAVEFORM:
Page 12 of 20
ADJACENT CHANNEL LEAKAGE RATIO (ACLR):
PROGRAM:
clc;
fs = 30.72e6;
t = 0:1/fs:1;
freq_4g = 2.5e6;
freq_5g = 3.5e6;
signal_4g = cos(2*pi*freq_4g*t);
signal_5g = cos(2*pi*freq_5g*t);
[Pxx_4g, f_4g] = pwelch(signal_4g, [], [], [], fs);
[Pxx_5g, f_5g] = pwelch(signal_5g, [], [], [], fs);
center_freq_4g = freq_4g;
adjacent_freq_4g = freq_4g + 5e6;
index_center_4g = find(f_4g == center_freq_4g);
index_adjacent_4g = find(f_4g == adjacent_freq_4g);
aclr_4g = 10*log10(Pxx_4g(index_adjacent_4g) / Pxx_4g(index_center_4g));
center_freq_5g = freq_5g;
adjacent_freq_5g = freq_5g + 5e6;
index_center_5g = find(f_5g == center_freq_5g);
index_adjacent_5g = find(f_5g == adjacent_freq_5g);
aclr_5g = 10*log10(Pxx_5g(index_adjacent_5g) / Pxx_5g(index_center_5g));
disp(['4G ACLR: ' num2str(aclr_4g) ' dB']);
disp(['5G ACLR: ' num2str(aclr_5g) ' dB']);
figure;
subplot(2, 1, 1);
semilogy(f_4g, Pxx_4g);
title('4G Signal Power Spectrum');
xlabel('Frequency (Hz)');
ylabel('Power/Frequency (dB/Hz)');
grid on;
subplot(2, 1, 2);
semilogy(f_5g, Pxx_5g);
title('5G Signal Power Spectrum');
xlabel('Frequency (Hz)');
ylabel('Power/Frequency (dB/Hz)');
grid on;
Page 13 of 20
OUTPUT WAVEFORM:
Page 14 of 20
EXPERIMENT 5: WIRELESS CHANNEL EQUALIZATION: ZERO-FORCING
EQUALIZER (ZFE), MMSE EQUALIZER (MMSEE),
ADAPTIVE EQUALIZER (ADE), DECISION FEEDBACK
EQUALIZER (DFE)
AIM:
APPARATUS REQUIRED:
1. Personal Computer
PROCEDURE:
2. Open new file and enter the program and save it.
4. Compile the program and check for any error and debug it.
Page 15 of 20
num_bit_errors = sum(data_symbols ~= equalized_bits);
bit_error_rate = num_bit_errors / num_symbols;
% Display results
disp(['Bit Error Rate (BER): ', num2str(bit_error_rate)]);
disp(['SNR (dB):', num2str(SNR_dB)]);
OUTPUT:
SNR (dB):20
Page 16 of 20
num_bit_errors = sum(data_symbols ~= equalized_bits);
bit_error_rate = num_bit_errors / num_symbols;
% Display results
disp(['Bit Error Rate (BER): ', num2str(bit_error_rate)]);
disp(['SNR (dB): ', num2str(SNR_dB)]);
OUTPUT:
SNR (dB): 20
Page 17 of 20
% Display results
disp(['Bit Error Rate (BER): ', num2str(bit_error_rate)]);
disp(['SNR (dB): ', num2str(SNR_dB)]);
OUTPUT:
SNR (dB): 20
MMSE EQUALIZER:
% Parameters
M = 4; % Number of transmitted symbols
N = 1000; % Number of received symbols
SNRdB = 10; % Signal-to-Noise Ratio in dB
pilotSymbols = [1 -1 1 -1]; % Known pilot symbols
% Generate random symbols
transmittedSymbols = randi([0 M-1], 1, N);
% Modulation
modulatedSymbols = qammod(transmittedSymbols, M);
% Channel
channel = [0.8 -0.4 0.2 -0.1]; % Example channel coefficients
channelOutput = filter(channel, 1, modulatedSymbols);
% Add noise
SNR = 10^(SNRdB/10);
noiseVar = 1/(2*SNR);
noise = sqrt(noiseVar) * randn(1, length(channelOutput));
receivedSignal = channelOutput + noise;
% Channel estimation using pilot symbols
pilotIndices = randperm(N, length(pilotSymbols));
pilotSignal = receivedSignal(pilotIndices);
estimatedChannel = conv(pilotSignal, conj(pilotSymbols(end:-1:1)));
estimatedChannel = estimatedChannel(end-length(channel)+1:end);
% MMSE equalization
equalizerCoefficients = conj(estimatedChannel) ./ (abs(estimatedChannel).^2 + noiseVar);
equalizedSymbols = filter(equalizerCoefficients, 1, receivedSignal);
% Demodulation
demodulatedSymbols = qamdemod(equalizedSymbols, M);
% Calculate bit error rate
bitErrors = sum(transmittedSymbols ~= demodulatedSymbols);
bitErrorRate = bitErrors / N;
disp(['Bit Error Rate: ' num2str(bitErrorRate)]);
OUTPUT:
Page 18 of 20
EXPERIMENT 6: MODELING AND SIMULATION OF TDMA, FDMA AND
CDMA FOR WIRELESS COMMUNICATION
AIM:
APPARATUS REQUIRED:
1. Personal Computer
PROCEDURE:
2. Open new file and enter the program and save it.
4. Compile the program and check for any error and debug it.
% Parameters
num_users = 4; % Number of users
num_symbols = 100; % Number of symbols
% Generate random data bits for each user
data_bits = randi([0, 1], num_users, num_symbols);
% TDMA - Time Division Multiple Access
tdma_symbols = zeros(num_users, num_symbols);
for user = 1:num_users
tdma_symbols(user, :) = data_bits(user, :) * 2 - 1; % Convert 0s to -1s and 1s to 1s
end
% FDMA - Frequency Division Multiple Access
fdma_symbols = zeros(num_users, num_symbols);
for user = 1:num_users
fdma_symbols(user, :) = data_bits(user, :) * 2 - 1; % Convert 0s to -1s and 1s to 1s
end
% CDMA - Code Division Multiple Access
% Generating random spreading codes
spreading_codes = randi([0, 1], num_users, num_symbols);
cdma_symbols = zeros(num_users, num_symbols);
for user = 1:num_users
cdma_symbols(user, :) = (data_bits(user, :) * 2 - 1) .* spreading_codes(user, :);
end
Page 19 of 20
% Plot TDMA, FDMA, and CDMA results
t = 1:num_symbols;
figure;
subplot(3, 1, 1);
plot(t, tdma_symbols', 'LineWidth', 1.5);
title('TDMA - Time Division Multiple Access');
xlabel('Symbol Index');
ylabel('Amplitude');
legend('User 1', 'User 2', 'User 3', 'User 4');
subplot(3, 1, 2);
plot(t, fdma_symbols', 'LineWidth', 1.5);
title('FDMA - Frequency Division Multiple Access');
xlabel('Symbol Index');
ylabel('Amplitude');
legend('User 1', 'User 2', 'User 3', 'User 4');
subplot(3, 1, 3);
plot(t, cdma_symbols', 'LineWidth', 1.5);
title('CDMA - Code Division Multiple Access');
xlabel('Symbol Index');
ylabel('Amplitude');
legend('User 1', 'User 2', 'User 3', 'User 4');
sgtitle('Modeling and Simulation of TDMA, FDMA, and CDMA for Wireless
Communication');
OUTPUT :
Page 20 of 20