├── Abode_Daniel_OFDM_code.m └── README.md /Abode_Daniel_OFDM_code.m: -------------------------------------------------------------------------------- 1 | %% Code on OFDM Exercise for Ph.D. Interview 2 | % Written by: Abode Daniel 3 | % Submitted: Jeremy Nadal on 27th of Jan, 2021 4 | close all 5 | clear all 6 | clc 7 | 8 | %% Declaring OFDM System Properties 9 | M = 64; % 64-QAM constellation 10 | k = log2(M); % number of bits per symbol 11 | N = k*2^16; % number of binary sequence 12 | num_sc = 256; % Number of Subcarrier 13 | num_dsc = 16; % Number of data subcarrier 14 | block_size = N/(num_dsc*k); % number of symbols per subcarrier 15 | cp_len = 64; % length of cyclic prefix 16 | 17 | %% Transmitter side 18 | ran = RandStream('swb2712'); 19 | input1 = randsrc(1,N,[0,1],ran); % Binary Sequence 20 | input = qammod(input1',M,'gray','InputType','bit','UnitAveragePower',true); %64QAM Modulation 21 | % Allocating the 64QAM Symbol to data subcarrier 22 | data_matrix = reshape(input, block_size, num_dsc); 23 | % ifft to generate 256 subcarriers 24 | ifft_data_matrix = ifft(data_matrix',num_sc)'; 25 | % Compute and append Cyclic Prefix 26 | cp_start = block_size-cp_len+1; 27 | actual_cp = ifft_data_matrix(cp_start:end,:); 28 | ifft_data = [actual_cp;ifft_data_matrix]; 29 | % Convert parallel to serial for transmission 30 | [rows_ifft_data, cols_ifft_data]=size(ifft_data); 31 | len_ofdm_data = rows_ifft_data*cols_ifft_data; 32 | ofdm_signal = reshape(ifft_data, 1, len_ofdm_data); % Actual OFDM signal to be transmitted 33 | 34 | %% Channel 35 | EbNo = [-10:20]; % Eb/No 36 | errors=zeros(size(EbNo)); 37 | for ii = 1:length(EbNo) 38 | snrdB = EbNo(ii) + 10*log10(k); %Conver Eb/No to snr in dB 39 | s = 1/sqrt(mean(abs(ofdm_signal).^2)); % Normalizer 40 | n = 1/sqrt(2)*(randn(1,len_ofdm_data) + 1i*randn(1,len_ofdm_data)); % normalized guassian noise 41 | % Pass the ofdm signal through the channel 42 | recvd_signal = s*ofdm_signal+10^(-snrdB/20)*n; % linear AWGN 43 | 44 | %% Receiver side 45 | % Convert Data back to "parallel" form to perform FFT 46 | recvd_signal_matrix = reshape(recvd_signal,rows_ifft_data, cols_ifft_data); 47 | % Remove CP 48 | recvd_signal_matrix(1:cp_len,:)=[]; 49 | % Perform FFT 50 | fft_data_matrix = fft(recvd_signal_matrix',num_sc)'; 51 | fft_data_matrix(:,num_dsc+1:end) = []; %Extract Data Symbols 52 | % Convert parallel to serial and Normalize 53 | y = reshape(fft_data_matrix, 1,[]); 54 | y=y./s; 55 | 56 | % Hard decision 57 | out1 = qamdemod(y,M,'gray','OutputType','bit','UnitAveragePower',true); 58 | out = reshape(out1,1,[]); 59 | 60 | errors(ii) = length(find(input1- out)); % calculate errors 61 | end 62 | ber1 = (errors/length(input1)); %simulation ber 63 | ber = berawgn(EbNo,'qam',M); %theoretical ber of single carrier 64 | 65 | %% BER plot 66 | figure 67 | semilogy(EbNo,ber1,'-x','linewidth',1.2); 68 | hold on; 69 | semilogy(EbNo,ber,'--','linewidth',1.2) 70 | hold off 71 | legend('simulation ber 16 of 256 subcarrier used','Theoretical ber of a single carrier','FontSize',15); 72 | title('BER Performance','FontSize',15) 73 | xlabel('Eb/No, dB','FontSize',15) 74 | ylabel('Log10(BER)','FontSize',15) 75 | ylim([0.5e-5 1]) 76 | 77 | %% Power Complementary Cumulative Distribution Function Derivation for OFDM 78 | for i = 1:num_sc %deriving the papr of all subcarriers 79 | PAPR(i)= 10*log10(max(abs(ifft_data(:,i)).^2)/mean(abs(ifft_data(:,i))).^2); 80 | end 81 | [Y,X] = hist(PAPR,200); 82 | figure 83 | plot(X,1-cumsum(Y)/max(cumsum(Y)),'-b', 'LineWidth',1.2); 84 | title('Power CCDF of OFDM','FontSize',15) 85 | xlabel('Power above Average Power, dB','FontSize',15) 86 | ylabel('Probability','FontSize',15) 87 | 88 | %% Q4 Power Complementary Cumulative Distribution Function Derivation for Single Carrier 89 | for i = 1:65536 90 | PAPR2(i) = 10*log10(max(abs(input.^2))/mean(abs(input(i)).^2)); 91 | end 92 | [Y1,X1] = hist(PAPR2,200); 93 | figure 94 | plot(X1,1-cumsum(Y1)/max(cumsum(Y1)),'-b', 'LineWidth',1.2); 95 | title('Power CCDF of Single Carrier 64QAM','FontSize',15) 96 | xlabel('Power above Average Power, dB','FontSize',15) 97 | ylabel('Probability','FontSize',15) 98 | 99 | %% Q4 Compare CCDF of OFDM and Single Carrier 64QAM 100 | figure 101 | plot(X1,1-cumsum(Y1)/max(cumsum(Y1)),'-b', 'LineWidth',1.2); 102 | title('Power CCDF Comparison of Single Carrier 64QAM and OFDM','FontSize',15) 103 | xlabel('Power above Average Power, dB','FontSize',15) 104 | ylabel('Probability','FontSize',15) 105 | hold on 106 | plot(X,1-cumsum(Y)/max(cumsum(Y)), 'LineWidth',1.2); 107 | legend('Power CCDF of 64QAM Single Carrier','Power CCDF of OFDM','FontSize',15) 108 | hold off 109 | 110 | %% Q5 Redesign of OFDM Transmitter using Selective Mapping Techniques 111 | for j = 1:20 %Performing the operation 40 times 112 | B = randsrc(1,num_dsc,[1 -1 -1i 1i],ran); %generate the phase sequence 113 | for i = 1:block_size 114 | d(i,:) = data_matrix(i,:).*B; %Multiplying our 64QAM data matrix by the random Phase Sequence 115 | end 116 | sig = ifft(d',num_sc); %ifft 117 | for i = 1:num_sc 118 | PAPR3(i)=10*log10(max(abs(sig(i,:)).^2)/mean(abs(sig(i,:))).^2); %calculating the PAPR 119 | end 120 | paprsum(j) = sum(PAPR3); %summing the PAPR 121 | % select signal with minimum PAPR 122 | if(paprsum(j) == min(paprsum (1:j))) 123 | sigmin = sig; 124 | end 125 | end 126 | 127 | %Calculating PAPR of selected signal 128 | for i = 1:num_sc 129 | PAPR3(i)=10*log10(max(abs(sigmin(i,:)).^2)/mean(abs(sigmin(i,:))).^2); 130 | end 131 | 132 | figure 133 | [Y3,X3] = hist(PAPR3,100); 134 | plot(X3,1-cumsum(Y3)/max(cumsum(Y3)),'-.b', 'LineWidth',1.2); 135 | title('Power CCDF Comparison of SLM Modified OFDM and OFDM','FontSize',15) 136 | xlabel('Power above Average Power, dB','FontSize',15) 137 | ylabel('Probability','FontSize',15) 138 | xlim([9 12]) 139 | hold on 140 | plot(X,1-cumsum(Y)/max(cumsum(Y)), 'LineWidth',1.2); 141 | legend('Power CCDF of SLM Modified OFDM','Power CCDF of OFDM','FontSize',15) 142 | hold off 143 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PAPR-Reduction-in-OFDM-using-Selective-Mapping-Technique 2 | This repository contains a MATLAB code comparing a conventional OFDM implementation and a modified OFDM system that uses Selective Mapping Techniques to reduce Peak to Average Power Ratio PAPR 3 | The OFDM implemented contains 256 subcarriers with the first 16 subcarriers carrying 64 QAM symbols. 4 | A (Bit Error Rate) BER plot and (Complementary Cumulative Distribution Function) CCDF plot was carried out to compare the performance of the OFDM system and a single carrier system. 5 | A modified OFDM system was designed using Selective Mapping Techniques to reduce the Peak to Average Power Ratio of the conventional OFDM system. 6 | The CCDF plot was use to compare the modified OFDM system and the conventional OFDM system 7 | --------------------------------------------------------------------------------