+ Post New Thread
Results 1 to 1 of 1
  1. #1
    Newbie level 1
    Points: 15, Level: 1

    Join Date
    May 2019
    Posts
    1
    Helped
    0 / 0
    Points
    15
    Level
    1

    How to implement 8PSK modulation in Matlab?

    Hi. I'm trying to implement 8psk on matlab. My SER looks fine but BER looks like wrong. Can you tell me my mistake? Thank you by now.

    Code:
    clc, clear all, close all
    N = 1e6-1;
    M = 8;
    k = log2(M);
    SNR_db = 0:12;
    max_b_sent = 3e7;
    
    mapping =[1/sqrt(2) (1+1i)/2 (0+1i)/sqrt(2) (-1+1i)/2 -1/sqrt(2) (-1-1i)/(2) (0-1i)/sqrt(2) (1-1i)/(2)];
    for m = 1:length(SNR_db)
        num_err = 0;
        num_tr = 0;
        num_symb_err = 0;
        num_symb_tr = 0;
        while (num_err<100) && (num_tr<max_b_sent)
              %Transmitter
              b = randi(2,1,N)-1;
              c = bi2de(reshape(b,k,N/k)','left-msb')';
              s = mapping(c+1);
              %AWGN Channel
              sigma = 10^(-SNR_db(m)/20);
              n = sigma*(1/sqrt(2))*(randn(1,N/k)+1i*randn(1,N/k));
              r = s+n;
              %Receiver
              Dist = [abs(r-mapping(1));abs(r-mapping(2));abs(r-mapping(3));abs(r-mapping(4));abs(r-mapping(5));abs(r-mapping(6));abs(r-mapping(7));abs(r-mapping(8))] ;
              [~,index] = min(Dist,[],1);
              c_est = index-1;
              b_est = reshape(de2bi(c_est,'left-msb')',1,N);
              num_err = num_err + sum(b~=b_est);
              num_tr = num_tr + N; 
              num_symb_err = num_symb_err + sum(c~=c_est);
              num_symb_tr = num_symb_tr + N/k;
        end
        ber(m) = num_err / num_tr ; 
        ser(m) = num_symb_err / num_symb_tr ; 
    end
    SNR_lin = 10.^(SNR_db/10);
    % SER theory
    ser_th = 2.*qfunc(sqrt(SNR_lin).*sin(pi/M));
    
    % BER theory
    
    ber_th = (1/M)*erfc(sqrt(SNR_lin*M)*sin(pi/M));
    %ber_th = qfunc(sqrt(SNR_lin));
    
    % SER drawing
    figure
    semilogy(SNR_db,ser,'*')
    hold on
    semilogy(SNR_db,ser_th,'r')
    
    % BER drawing
    figure
    ebno = SNR_db-10*log10(k);
    semilogy(ebno,ber,'*')
    hold on
    semilogy(ebno,ber_th,'r')
    Last edited by ads-ee; 21st May 2019 at 01:27. Reason: added code tags

    •   AltAdvertisement

        
       

--[[ ]]--