Ber computation for frequency selective fading

12 views (last 30 days)
I have the following matlab code clc; clear all; close all; N = 128; % No of subcarriers Ncp = 16; % Cyclic prefix length Ts = 1e-3; % Sampling period of channel Fd = 0; % Max Doppler frequency shift Np = 4; % No of pilot symbols M = 2; % No of symbols for PSK modulation Nframes = 10^3; % No of OFDM frames D = round((M-1)*rand((N-2*Np),Nframes)); %D=rand(1,Nframes); const = pskmod([0:M-1],M); r=3.56995; %r=2.9; n=999; m0=.6; m(1)=m0; for i=1:n m(i+1)=r*m(i)*(1-m(i));
end
Dmod2 = pskmod(D,M); Dmod1=real(Dmod2); m1=m.'; Dmod=Dmod1.*m1;
Data = [zeros(Np,Nframes); Dmod ; zeros(Np,Nframes)]; % Pilot Insertion
%% OFDM symbol
IFFT_Data = (128/sqrt(120))*ifft(Data,N); TxCy = [IFFT_Data((128-Ncp+1):128,:); IFFT_Data]; % Cyclic prefix [r c] = size(TxCy); Tx_Data = TxCy;
%% Frequency selective channel with 4 taps
tau = [0 1e-5 3.5e-5 12e-5]; % Path delays pdb = [0 -1 -1 -3]; % Avg path power gains h = rayleighchan(Ts, Fd, tau, pdb); h.StoreHistory = 0; h.StorePathGains = 1; h.ResetBeforeFiltering = 1;
%% SNR of channel
EbNo = -7:20; EsNo= EbNo + 10*log10(120/128)+ 10*log10(128/144); % symbol to noise ratio snr= EsNo - 10*log10(128/144); Ec_N0_dB = EbNo - 10*log10(4);
%% Transmit through channel
berofdm = zeros(1,length(Ec_N0_dB)); Rx_Data = zeros((N-2*Np),Nframes); for i = 1:length(Ec_N0_dB) for j = 1:c % Transmit frame by frame hx = filter(h,Tx_Data(:,j).'); % Pass through Rayleigh channel a = h.PathGains; AM = h.channelFilter.alphaMatrix; g = a*AM; % Channel coefficients G(j,:) = fft(g,N); % DFT of channel coefficients y = awgn(hx,Ec_N0_dB(i)); % Add AWGN noise
%% Receiver
Rx = y(Ncp+1:r); % Removal of cyclic prefix
FFT_Data = (sqrt(120)/128)*fft(Rx,N)./G(j,:); % Frequency Domain Equalization
Rx_Data(:,j) = pskdemod(FFT_Data(5:124),M); % Removal of pilot and Demodulation
end
berofdm(i) = sum(sum(Rx_Data~=D))/((N-2*Np)*Nframes);
end
%% Plot the BER EbN0Lin = 10.^(EbNo/10); theoryBer = 0.5.*(1-sqrt(EbN0Lin./(EbN0Lin+1)));
figure; semilogy(EbNo,theoryBer,'bs-','linewidth',2); hold on semilogy(EbNo,berofdm,'mx-','linewidth',2); axis([-7 20 10^-3 2]) grid on; title('OFDM BER vs SNR in Frequency selective Rayleigh fading channel'); xlabel('EbNo'); ylabel('BER'); But It is showing error in multiplying Dmod1 and m1. Can anyone plz help me?

Answers (0)

Categories

Find more on Propagation and Channel Models in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!