israilsaifi
Newbie level 1
rayleigh fading simulation
how one can generate two path fading and transmiits ddata on it in matlab ?
how one can generate two path fading and transmiits ddata on it in matlab ?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
could u pls anyone explain me how can i use the 'rayleighchan' function in loop for simulation of ofdm system..
i passed the say 100 symbols through this rayleighchan function and i added indivually awgn ...then after demodulation i ploted the ber curve.
i am appending my code..is my code is correct..pls correct it if any wrong..
and also pls let me know abt how can i modify the code for working in case of varying dopler frequency..
<-----------------------------**********************------------------------------->
% ofdm system design ...
% BW = input('enter the channel bandwidth :');
% Nused = input('enter the number of subcarriers :');
% n_factor = input('enter the sampling factor :');
% G = input('enter the ration of CP time to Useful time :');
clear all
close all
clc
BW = 1.75e6;
Nused = 200;
n_factor = 8/7;
G = 1/4;
[Nfft,Fs,delta_f,Tb,Tg,Ts,sampling_time] = derived_parameters(BW,Nused,n_factor,G);
% Nfft-->fft size , Fs-->sampling frequency , delta_f-->suhcarrier spacing
% Tb--> useful symbol time, Tg-->guard/CP time, Ts-->OFDM Symbol
% time (Tb+Tg)
N_prefix = Nfft*G;
N_data = 192;
N_pilot = 8;
SNR = 0:2:20; % snr in db
M = 4; % order of modulation
n = log2(M); % no. of bits per symbol
% chan = rayleighchan(sampling_time,200);
% chan.resetbeforefiltering = 0;
ber_final = zeros(1,length(SNR));
no_of_symbols = 100;
%chan.resetbeforefiltering =0;
for i = 1:length(SNR)
i
test_1 = [];
test_2 = [];
errors_new = 0;
for j=1:no_of_symbols
x_user = floor(M*rand(N_data,1));
test_1 = [test_1,x_user.'];
%x_user = floor(M*rand(Nfft,1));
X_mod_out = qammod(x_user,M).';
% subcarrier_out = subcarrier_mapping(X_mod_out.',Nfft);
% subcarrier mapping
subcarrier_out = zeros(Nfft,1);
subcarrier_out([29:40,42:65,67:90,92:115,117:128,130:141,143:166,168:191,193:216,218:229]) = X_mod_out;
% % processing information for getting timedomain waveform
% subcarrier_out = X_mod_out;
x_out = tx_sub_part(subcarrier_out,Nfft);
x_ofdm_symbol = [x_out(Nfft-N_prefix+1:end),x_out].';
% channel generation and passing the signal through fading channel
%chan = rayleighchan(sampling_time,2,[0,1.5e-5,3.2e-5],[0,-3,-3]);
%chan.StoreHistory = 0;
chan = rayleighchan(sampling_time,100);
%chan = rayleighchan(sampling_time,10,[0,Tg/4],[0,-20]);
% chan.resetbeforefiltering = 0;
%chan = ricianchan(sampling_time,4,[0,Tg/10],[0,-9],10);
y_fading = filter(chan,x_ofdm_symbol);
gain_c = chan.pathgains;
Gain_c = fft(gain_c,Nfft).';
% pasing signal through awgn channel
y_awgn = awgn(y_fading,SNR(i),'measured');
% removing the cycling prefix part
% it is also known as synchronisation part
% here perfect synchronisation is assued
y_received = y_awgn(N_prefix+1:end);
% one tap equalizer is implimented below
eq_out = y_received./Gain_c;
r_out = rx_sub_part(eq_out.',Nfft);
%demap_out = subcarrier_demap(r_out);
% getting information symbols by subcarrier demapping
demap_out = r_out([29:40,42:65,67:90,92:115,117:128,130:141,143:166,168:191,193:216,218:229]);
%demap_out = r_out;
% demodulation of the signal
x_cap = qamdemod(demap_out,M);
test_2 = [test_2,x_cap.'];
%[ no_of_errors,BER ] = biterr(x_cap,x_user);
%errors_new = errors_new + no_of_errors;
end
[ no_of_errors,BER(i) ] = biterr(test_1,test_2);
%ber_final(i) = errors_new/(N_data*no_of_symbols);
end
semilogy(SNR,BER);
xlabel('SNR in dB');
ylabel('BER Values');
title('SNR Vs BER plot');
% this programme is for subpart of the transmitter...
% input--> Xin : out put of modulator
% Nfft : FFT size
% output--> x_out : time domain version ( 1xNfft )
function [x_out] = tx_sub_part(Xin,Nfft)
[x_out] = ifft(Xin.',Nfft);
end
% this function is for implimenting the subpart of the receiver
% input--> r_in : output of the channel
% Nfft : FFT size
% output--> R_out : frequency domain version of the received signal
% (1xNfft)
function [R_out] = rx_sub_part(r_in,Nfft)
[R_out] = fft(r_in.',Nfft);
end
<---------------------------********************---------------------------------->
thanx regards..
uday