You are on page 1of 6

Assignment - PBL

Q.1 Consider a wideband channel with the following continuous multipath power
delay and write a MATLAB Code to calculate the mean Delay, RMS delay, coherence
bandwidth and the maximum symbol rate of the system that avoids ISI.
Sol.1-
% Wideband channel parameters
tau = 0:0.001:1; % Delay values in seconds
p_tau = exp(-tau/0.00001); % Power delay profile
% Mean delay
mean_delay = trapz(tau, tau.*p_tau);
% RMS delay
rms_delay = sqrt(trapz(tau, (tau-mean_delay).^2.*p_tau));
% Coherence bandwidth
coherence_bw = 1/(2*pi*rms_delay);
% Maximum symbol rate
max_symbol_rate = 1/(2*rms_delay);
% Display the results
disp(['Mean delay: ' num2str(mean_delay*1e6) ' microseconds']);
disp(['RMS delay: ' num2str(rms_delay*1e6) ' microseconds']);
disp(['Coherence bandwidth: ' num2str(coherence_bw/1e6) ' MHz']);
disp(['Maximum symbol rate: ' num2str(max_symbol_rate/1e6) ' Msymbols/s']);

Q.2 Consider a discrete PDP given as a list of power values in dBm Ps = [- 20; -10; -
10; 0] and the corresponding delays in μs = [0; 10; 20; 50].
Write a MATLAB Code to calculate the mean Delay, RMS delay, coherence
bandwidth and the maximum symbol rate of the system that avoids ISI.
Sol.2-
% Input parameters
Ps = [-20, -10, -10, 0]; % power values in dBm
delays = [0, 10, 20, 50]; % delays in μs
% Convert dBm to linear scale
P = 10 .^ (Ps ./ 10);

% Calculate the mean delay


mean_delay = sum(P .* delays) / sum(P);

% Calculate the RMS delay


rms_delay = sqrt(sum(P .* delays .^ 2) / sum(P) - mean_delay ^ 2);

% Calculate the coherence bandwidth


coherence_bw = 1 / (2 * pi * rms_delay);

% Calculate the maximum symbol rate


max_sym_rate = 1 / (2 * mean_delay);

% Display the results


fprintf('Mean Delay = %.2f us\n', mean_delay);
fprintf('RMS Delay = %.2f us\n', rms_delay);
fprintf('Coherence Bandwidth = %.2f MHz\n', coherence_bw / 1e6);
fprintf('Maximum Symbol Rate = %.2f Mbps\n', max_sym_rate / 1e6);
Output-
Mean Delay = 28.57 us
RMS Delay = 19.64 us
Coherence Bandwidth = 0.41 MHz
Maximum Symbol Rate = 17.50 Mbps

Q.3 Write a MATLAB Code to evaluate error rate Performance of MPSK-CP-OFDM


and MQAM-CP-OFDM over and AWGN channel.
Sol.3-
% Define the parameters
M = 4; % M-ary modulation (MPSK or MQAM)
N = 64; % FFT size
cp_len = 16; % Length of cyclic prefix
num_bits = 1e6; % Number of bits to transmit
snr_db = 0:2:20; % SNR range in dB
% Generate random data
data = randi([0 M-1], 1, num_bits);
% Modulation
if M == 4
modulated_data = pskmod(data, M); % MPSK modulation
else
modulated_data = qammod(data, M); % MQAM modulation
end
% Reshape data into N subcarriers
modulated_data_reshape = reshape(modulated_data, N, []);
% Perform IFFT
ifft_data = ifft(modulated_data_reshape, N);
% Add cyclic prefix
ifft_data_cp = [ifft_data(N-cp_len+1:N,:); ifft_data];
% Serial to parallel conversion
tx_signal = ifft_data_cp(:);
Loop over SNR range
for snr_idx = 1:length(snr_db)
% Add noise to the signal
rx_signal = awgn(tx_signal, snr_db(snr_idx), 'measured');
% Parallel to serial conversion
rx_signal_p2s = reshape(rx_signal, N+cp_len, []);
% Remove cyclic prefix
rx_signal_no_cp = rx_signal_p2s(cp_len+1:end,:);
% Perform FFT
fft_data = fft(rx_signal_no_cp, N);
% Reshape data back into a vector
rx_data = reshape(fft_data, [], 1);
% Demodulation
if M == 4
rx_demod_data = pskdemod(rx_data, M); % MPSK demodulation
else
rx_demod_data = qamdemod(rx_data, M); % MQAM demodulation
end
% Calculate bit errors
num_errors(snr_idx) = sum(rx_demod_data ~= data);
end
% Calculate bit error rate
ber = num_errors / num_bits;
% Plot the results
figure;
semilogy(snr_db, ber);
xlabel('SNR (dB)');
ylabel('Bit Error Rate');
title(sprintf('BER Performance of %d-PSK/M-QAM CP-OFDM over AWGN Channel', M));

Q.4 Write a MATLAB Code to evaluate error rate Performance of MPSK-CP-OFDM


and MQAM-CP-OFDM over frequency selective Rayleigh Channel.
Sol.4-
% OFDM Parameters
N = 64; % Number of subcarriers
M = 4; % Modulation order (4 for QPSK, 16 for 16-QAM, etc.)
K = log2(M); % Bits per symbol
P = 4; % Cyclic prefix length
% Channel Parameters
SNR_dB = 0:2:20; % SNR in dB
SNR = 10.^(SNR_dB/10); % SNR in linear scale
num_channels = 10; % Number of independent Rayleigh channels
% Generate random data
data = randi([0 1], N*K, 1);
% Modulation
if M==4
mod_data = qammod(data,M);
else
mod_data = qammod(data,M,'gray');
end
% Reshape data to N subcarriers
mod_data_matrix = reshape(mod_data,N,K);
% IFFT
ifft_data = ifft(mod_data_matrix,N,2);
% Add Cyclic Prefix
tx_data = [ifft_data(:,(end-P+1):end) ifft_data];
% Convert to serial
tx_data_serial = tx_data(:);
% Rayleigh fading channel
for i=1:length(SNR)
% Noise variance
noise_var = 1/SNR(i);
% Generate noise vector
noise = sqrt(noise_var/2)*(randn(size(tx_data_serial))+1i*randn(size(tx_data_serial)));
% Generate Rayleigh fading channels
h = sqrt(1/2)*(randn(size(tx_data_serial))+1i*randn(size(tx_data_serial)));

% Apply channel and add noise


rx_data_serial = zeros(size(tx_data_serial));
for k=1:num_channels
rx_data_serial = rx_data_serial + filter(h(:,k),1,tx_data_serial) + noise(:,k);
end
% Convert to parallel
rx_data = reshape(rx_data_serial,length(rx_data_serial)/N,N);
% Remove Cyclic Prefix
rx_data = rx_data(:,(P+1):end);
% FFT
fft_data = fft(rx_data,N,2);
% Demodulation
if M==4
demod_data = qamdemod(fft_data,M);
else
demod_data = qamdemod(fft_data,M,'gray');
end
% Reshape demodulated data
demod_data_matrix = reshape(demod_data,N*K,1);
% Calculate Bit Error Rate (BER)
[err, ~] = biterr(data, demod_data_matrix);
BER(i) = err/(N*K*num_channels);
end
% Plot the results
semilogy(SNR_dB,BER);
grid on;
xlabel('SNR (dB)');
ylabel('Bit Error Rate');
title('MPSK-CP-OFDM and MQAM-CP-OFDM Performance over Frequency Selective Rayleigh
Channel');
legend('MPSK-CP-OFDM','MQAM-CP-OFDM');

You might also like