Matlab Program O-P
Matlab Program O-P
PROGRAM :
WIRELESS CHANNEL SIMULATION INCLUDING FADING AND DOPPLER EFFECTS
% Define Parameters
sampleRate500kHz = 500e3; % Sample rate of 500 KHz
sampleRate20kHz = 20e3; % Sample rate of 20 KHz
maxDopplerShift = 200; % Max Doppler shift of diffuse components (Hz)
delayVector = (0:5:15) * 1e-6; % Discrete delays of 4-path channel (s)
gainVector = [0 -3 -6 -9]; % Average path gains (dB)
KFactor = 10; % Rician K-factor (linear ratio)
specDopplerShift = 100; % Doppler shift of specular component (Hz)
% QPSK Modulator
qpskMod = comm.QPSKModulator( ...
'BitInput', true, ...
'PhaseOffset', pi/4);
% Number of bits per frame
bitsPerFrame = 1000; % 500 symbols per frame for QPSK
msg = randi([0 1], bitsPerFrame, 1); % Generate random bits
% Disable Visualization
release(rayChan);
rayChan.Visualization = 'Off';
release(ricChan);
ricChan.Visualization = 'Off';
% Match Sample Rate and Delays between Rayleigh and Rician Channels
ricChan.SampleRate = rayChan.SampleRate;
ricChan.PathDelays = rayChan.PathDelays;
ricChan.AveragePathGains = rayChan.AveragePathGains;
fprintf('\nFor an EbNo setting of %3.1f dB, the bit error rate is %5.2e, based on %d errors.\n', ...
EbNo, ber, numErrors);
%===================================================================
=====
% The mfile investigates the generation, transmission and reception of
% the OFDM signal without channel noise or HPA effect
%===================================================================
=====
clear all;
clc;
close all;
% A: Setting Parameters
M = 4; % QPSK signal constellation
no_of_data_points = 64; % Number of data points
block_size = 8; % Size of each OFDM block
cp_len = ceil(0.1 * block_size); % Length of cyclic prefix
no_of_ifft_points = block_size; % Points for the IFFT
no_of_fft_points = block_size; % Points for the FFT
% 5. Remove CP
recvd_signal_matrix(1:cp_len, :) = []; % Remove the cyclic prefix
% 6. Perform FFT
for i = 1:cols_ifft_data
fft_data_matrix(:, i) = fft(recvd_signal_matrix(:, i), no_of_fft_points);
end
figure(5);
stem(qpsk_demodulated_data, 'rx');
grid on;
xlabel('Data Points');
ylabel('Received Data Phase Representation');
title('Received Data "X"');
EXP NO - 11
Program:
% LTE Parameters
enb.NDLRB = 15; % Number of resource blocks
enb.CellRefP = 1; % One transmit antenna port
enb.NCellID = 10; % Cell ID
enb.CyclicPrefix = 'Normal'; % Normal cyclic prefix
enb.DuplexMode = 'FDD'; % FDD
SNRdB = 22; % Desired SNR in dB
SNR = 10^(SNRdB/20); % Linear SNR
rng('default'); % Configure random number generators
cfg.Seed = 1; % Channel seed
cfg.NRxAnts = 1; % 1 receive antenna
cfg.DelayProfile = 'EVA'; % EVA delay spread
cfg.DopplerFreq = 120; % 120Hz Doppler frequency
cfg.MIMOCorrelation = 'Low'; % Low (no) MIMO correlation
cfg.InitTime = 0; % Initialize at time zero
cfg.NTerms = 16; % Oscillators used in fading model
cfg.ModelType = 'GMEDS'; % Rayleigh fading model type
cfg.InitPhase = 'Random'; % Random initial phases
cfg.NormalizePathGains = 'On'; % Normalize delay profile power
cfg.NormalizeTxAnts = 'On'; % Normalize for transmit antennas
% Initialize Variables
txGrid = []; % Transmit Resource Grid
% Generate Subframes
for sf = 0:10
% Set subframe number
enb.NSubframe = mod(sf, 10);
% OFDM Modulation
[txWaveform, info] = lteOFDMModulate(enb, txGrid);
txGrid = txGrid(:, 1:140);
cfg.SamplingRate = info.SamplingRate;
% Channel Estimation
[estChannel, noiseEst] = lteDLChannelEstimate(enb, cec, rxGrid);
eqGrid = lteEqualizeMMSE(rxGrid, estChannel, noiseEst);
subplot(1, 2, 2);
imagesc(abs(eqGrid));
title('Equalized Grid');
xlabel('Subcarriers');
ylabel('OFDM Symbols');
colorbar;