Watch kzbin.info/www/bejne/hXiqo4FnitqXhMU for Simulink Simulation of OFDM communication system to get its BER Watch kzbin.info/www/bejne/Z4vEXphpd8qhn9U for Simulink Simulation of coherent 4-FSK passband signaling to measure the SER Watch kzbin.info/www/bejne/a568gKakaMx9i9k for MATLAB Simulation of DPSK (Differential PSK) passband signaling to measure the BER Watch kzbin.info/www/bejne/eIeseZyhataioa8 for Simulink Simulation of DPSK (Differential PSK) passband signaling to measure the SER Watch kzbin.info/www/bejne/aoW3eoufjbiIb8U for Simulink Simulation of noncoherent FSK passband signaling to measure the SER Watch kzbin.info/www/bejne/h3a9nHqwg9yWfMk for MATLAB Simulation of noncoherent FSK passband signaling to measure the SER Watch kzbin.info/www/bejne/bXXbfGlpZrCqq80 for MATLAB Simulation of coherent FSK passband signaling to measure the SER Watch kzbin.info/www/bejne/apS0dJufadNki7s for MATLAB Simulation of QAM passband signaling to measure the BER Watch kzbin.info/www/bejne/gZWvoICfYst8i5Y for Simulink Simulation of QAM passband signaling to measure the SER Watch kzbin.info/www/bejne/nJu3nJWEnd51nZo for MATLAB Simulation of PSK passband signaling to measure the BER Watch kzbin.info/www/bejne/h5u0hZJmqtFqb80 for Simulink Simulation of PSK passband signaling to measure the BER %sim_QAM_passband.m % simulates a digital communication system in Fig.7.13 % with QAM signal waveforms in Fig.7.11 clear, clf b=4; M=2^b; L=2^(b/2); % # of bits per symbol and modulation order Tb=1e-5; Ts=b*Tb; % Bit/Symbol duration Nb=16; Ns=b*Nb; % # of subintervals in Ts T=Ts/Ns; LB=4*Ns; LBN1=LB-Ns+1; % the subinterval length and buffer size ssc=bin2gray(0:L-1,'ask',L); sss=ssc; wc=8*pi/Ts; wcT=wc*T; t=[0:Ns-1]*T; % Unit signal waveforms for the quadrature multiplier of transmitter su=sqrt(2/Ts)*[cos(wc*t); -sin(wc*t)]; suT=su*T; % Unit signal waveforms for the quadrature multiplier of receiver %Esum=0; % 16-QAM signal waveforms corresponding to rectangular constellation for i=1:L for l=1:L s(i,l,1)=2*i-L-1; s(i,l,2)=2*l-L-1; %In-phase/quadrature amplitude %Esum= Esum+s(i,l,1)^2 +s(i,l,2)^2; ss(L*(l-1)+i,:)=[ssc(i,:) sss(l,:)]; sw(L*(l-1)+i,:)=s(i,l,1)*su(1,:)+s(i,l,2)*su(2,:); end end %Eav_=Esum/M Eav=2*(M-1)/3 % Eq.(7.5.4a) Es=2; % the energy of signal waveform A=sqrt(Es/Eav); sw=A*sw; levels=A*[-(L-1):2:L-1]; gs=['s+xs'; 'd*'; 's+xs']; % graphic symbols SNRdBs=[1:15]; N_Iter=10000; % Range of SNRbdB and # of iterations for iter=1:length(SNRdBs) SNRbdB=SNRdBs(iter); SNRb=10^(SNRbdB/10); %SNRdB=SNRbdB+10*log10(b); sigma2=(Es/b)/SNRb; sgmsT=sqrt(sigma2/T); yr=zeros(2,LB); % Initialize the multiplier buffer nobe=0; % Initialize the number of bit errors to be accumulated for k=1:N_Iter im=ceil(rand*L); in=ceil(rand*L); imn=(in-1)*L+im; s=ss(imn,:); % Transmitted signal for n=1:Ns % Operation per symbol interval wct=wcT*(n-1); bp_noise=randn*cos(wct)-randn*sin(wct); % Bandpass noise rn=sw(imn,n)+sgmsT*bp_noise; % Received signal with noise %rn= awgn(sw(imn,n),SNRdB-10*log10(Ns/Ts)-3); %received signal yr=[yr(:,2:LB) suT(:,n)*rn]; % Multiplier end ycsk=sum(yr(:,LBN1:LB)'); % Sampled correlator output - DTR input %yck=ycsk(1); ysk=ycsk(2); %Detector(DTR)levels if iter==10&k100; break; end end pobe(iter)= nobe/(k*b); end % Add the reference signal points to the signal constellation diagram for n=1:L, plot(levels,levels(n)*ones(1,L),'ro'); end axis([-2 2 -2 2]), axis('equal'), set(gca,'fontsize',9) title(['Received signal constellation for SNRdB=' num2str(SNRdBs(10))]) % Plot the BERs obtained from simulation with the theoretical BER curve SNRbdBt=0:.1:15; SNRbt=10.^(SNRbdBt/10); %Pm=2*(1-1/L)*Q(sqrt(3/2*b*SNRbt/(M-1))); % Eq.(7.1.5) %poe_on_theory= (1-(1-Pm).^2)/b; % Eq.(7.5.8) poe_on_theory=prob_error(SNRbdBt,'QAM',b,'BER'); subplot(222) semilogy(SNRbdBt,poe_on_theory,'k-', SNRdBs,pobe,'b*') axis([0 SNRdBs(end) 1e-4 1]), set(gca,'fontsize',9), grid on title('Probability of Bit Error for (16-ary) QAM Signaling') set(gcf,'color','white') function [grayCode,grayCode_s,map]=bin2gray(xin,signaling,M) % Input: % xin = Integer(s) to be graycoded. % signaling = 'ask'|'psk'|'qam' % M = Modulation order % Output: % grayCode = Binary form % grayCode_s = String form % map = Grade code map in string form signaling=lower(signaling); if signaling=='ask'|signaling=='pam' log2M=log2(M); binVal = de2bi(xin,log2M,'left-msb'); % Convert binary to Gray code grayCode = binVal; grayCode(:,2:end) = xor(binVal(:,1:end-1), binVal(:, 2:end)); binVals = de2bi([0:M-1],log2M,'left-msb'); grayCodes = binVals; grayCodes(:,2:end) = xor(binVals(:,1:end-1), binVals(:, 2:end)); for m=1:size(grayCode,1) grayCode_s(m,:)=removeBlanks(num2str(grayCode(m,:))); % String form end for m=1:size(grayCodes,1) map{m}=removeBlanks(num2str(grayCodes(m,:))); % String form end for m=1:numel(xin) grayCode_s1(m,:)=map{xin(m)+1}; % String form end elseif signaling=='qam' b=log2(M); L=2^(b/2); graycode=bin2gray([0:L-1],'ask',L); i=0; for m=1:L for n=1:L i = i+1; grayCodes(i,:)=[graycode(n,:) graycode(m,:)]; map{L-m+1,n}=removeBlanks(num2str(grayCodes(i,:))); end end %grayCode0 grayCode=grayCodes(xin+1,:); % Binary integer form for m=1:size(grayCode,1) grayCode_s(m,:)=removeBlanks(num2str(grayCode(m,:))); % String form end elseif signaling=='psk' b=ceil(log2(M)); grayCodes=[0; 1]; for n=2:b m=size(grayCodes,1); grayCodes=[zeros(m,1) grayCodes; ones(m,1) flipud(grayCodes)]; end grayCode=grayCodes(xin+1,:); % Binary integer form for m=1:size(grayCodes,1) map{m}=removeBlanks(num2str(grayCodes(m,:))); % String form end for m=1:numel(xin) grayCode_s(m,:)=map{xin(m)+1}; % String form end else fprintf(" Please specify the 2nd input argument signaling as one of 'ask'|'psk','qam'") end end function p=prob_error(SNRbdB,signaling,b,opt1,opt2) % Finds the symbol/bit error probability for given SNRbdB=Eb/(N0/2)[dB](Table 7.1) % Note that EbN0dB=SNRbdB-3. % Copyleft: Won Y. Yang, wyyang53@hanmail.net, CAU for academic use only if nargin1))*Q(sqrt(b*SNRb)*sin(pi/M)); %Eq.(7.3.7) if lower(opt1(1))=='b'&b>1, p=p/b; end elseif signaling(1:3)=='DPS' %DPSK for i=1:NSNR EbN0=SNRb(i)/b; % From the MATLAB built-in function berawgn() tol=1e-6; % tol=max(min(1e-4/EbN0.^5,1e-4),eps); int_dpsk=@(y,EbN0,M,b)exp(-b*EbN0*(sin(pi/M))^2./(1+sqrt(1-(sin(pi/M)).^2).*cos(y))); %?????? p(i)=1/pi*quad(int_dpsk,1e-5,pi*(1-1/M),tol,[],EbN0,M,b); end if lower(opt1(1))=='b', p=p/b; end elseif signaling(1:3)=='QAM' L = 2^(ceil(b/2)); N = M/L; tmpL = 1-2*(L-1)/L*Q(sqrt(3*b/2/(L^2-1)*SNRb)); tmpN = 1-2*(N-1)/N*Q(sqrt(3*b/2/(N^2-1)*SNRb)); p = 1-tmpL.*tmpN; %Eq.(7.5.6) if lower(opt1(1))=='b'&b>1, p = p/b; end end end function newStr=removeBlanks(str) newStr = str(~isspace(str)); end