+ Post New Thread
Results 1 to 1 of 1

21st May 2019, 01:01 #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 = 1e61; 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) (11i)/(2) (01i)/sqrt(2) (11i)/(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)','leftmsb')'; 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(rmapping(1));abs(rmapping(2));abs(rmapping(3));abs(rmapping(4));abs(rmapping(5));abs(rmapping(6));abs(rmapping(7));abs(rmapping(8))] ; [~,index] = min(Dist,[],1); c_est = index1; b_est = reshape(de2bi(c_est,'leftmsb')',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_db10*log10(k); semilogy(ebno,ber,'*') hold on semilogy(ebno,ber_th,'r')
Last edited by adsee; 21st May 2019 at 01:27. Reason: added code tags

Advertisement
+ Post New Thread
Please login