📄 p16.m
字号:
% ===================================================================
% Aim : Simulation of 16-QAM-OFDM Orthogonal-PD+TWTA for AWGN channel
% Date : 21/05/2007
% Name : Nibaldo Rodriguez
% Update: 21/05/2007
% ===================================================================
close all
clear
load pesos
Nc=256; % subcarrier Numbers
M=16; % Constellation size
Nblock=ceil(1e4/(log2(M)*Nc))% block Numberr
L=log2(M)*Nc*Nblock; % Transmission Bits
Constellation =constela(log2(M));
Constellation=reshape(Constellation,M,1);
CC=Constellation;
fprintf('Waiting ...Mr...\n');
SNRinic=15;
SNRend=15;
SNRInc=0.5;
Iterations=40;
kk=0;
ibo=power(10,0/10);
randn('seed',sum(100*clock));
for snr=SNRinic:SNRInc:SNRend
EbNo=power(10,-snr/10); % average SNR per bits
ber=zeros(1,Iterations);% BER partial by itertions
for iter=1:Iterations
x=round(rand(1,L)); % gennerated bits
q=modula(x,M,Constellation); % QAM
S_P=reshape(q,Nc,Nblock); % Serial to Parallel
SymOfdm=sqrt(Nc)*ifft(S_P,Nc); % Multicarrier Modulation
SymTx=reshape(SymOfdm,1,Nc*Nblock); % Parallel to Serial
%=================================
% Amplification TWTA
SymTx=ibo*SymTx;
ps=angle(SymTx);
r=abs(SymTx);
% r(find(r==0))=eps;
wo=max(abs(r));
My= pd_orto((r./wo),H,v,w);
Ny=My.^2./(1+My.^2);
Ny=Ny.*(pi/3);
y=My.*exp(-j.*Ny).*exp(j.*ps');
% y=(SymTx./r).*y';
z=twtaa(y,wo);
% ==== AWGN Chhanel=====
Eb1=sum(real(z).^2)./L;
Eb2=sum(imag(z).^2)./L;
Eb=Eb1+Eb2;
N_o=Eb*EbNo;
sigma=sqrt(N_o/2);
nr=sigma.*randn(1,length(z));
ni=sigma.*randn(1,length(z));
noise=nr+sqrt(-1).*ni;
%====Receiver ============
rx=z+noise';
rx_sp=reshape(rx,Nc,Nblock); % Serial to Parallel
rx_q=(1/sqrt(Nc))*fft(rx_sp,Nc); % Multicarrier Demodulation OFDM
rx_ps=reshape(rx_q,1,Nc*Nblock); % Parallel to Serial
%=========== QAM Demodulation
Len=length(rx_ps);
for i=1:Len
[a,index(i)]=min(abs(rx_ps(i)-Constellation(:)));
end
bit2=de2bi(index-1,log2(M));
xx=reshape(bit2',1,length(x));
err=sum(ne(x,xx));
ber(iter)=err/L; % Ber partial
fprintf('\n Iter %d BER %f',iter,ber(iter))
end
kk=kk+1;
AvgBer(kk)=sum(ber(:))/Iterations;
fprintf('\n SNR db %2.2f Avg BER %f',snr,AvgBer(kk))
save bof16 AvgBer
end
%
%
% t=SNRinic:SNRInc:SNRend;
% a=6:0.25:14; %13.75 %19;
% b=bteo(a,M);
% figure(1)
% semilogy(t,AvgBer,'-*r',a,b,'-+k')
% xlabel('SNR dB')
% ylabel('B E R ')
% grid on
% figure(2)
% plot(dd,'+')
% grid on
%
m1=sum(norm(q-rx_ps).^2);
m2=sum(norm(q).^2);
EE=100*(1-sqrt(m1/m2))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -