logo资料库

MPAM调制和QPSK调制.doc

第1页 / 共17页
第2页 / 共17页
第3页 / 共17页
第4页 / 共17页
第5页 / 共17页
第6页 / 共17页
第7页 / 共17页
第8页 / 共17页
资料共17页,剩余部分请下载后查看
Project 3 Project2中得到比特流map4bit map8bit 2- then I created 2-PAM modulator . the script name: project3_2PAM: clc A=0.44721; PAM2bit8=1:1:262144*4'; PAM2bit4=1:1:262144*2'; m=1; n=1; v=1; while v~=262145; PAM2bit4(m)=bin2dec(map4bit(v:v,1:2))*A; m=m+1; PAM2bit4(m)=bin2dec(map4bit(v:v,3:4))*A; m=m+1; PAM2bit8(n)=bin2dec(map8bit(v:v,1:2))*A; n=n+1; PAM2bit8(n)=bin2dec(map8bit(v:v,3:4))*A; n=n+1; PAM2bit8(n)=bin2dec(map8bit(v:v,5:6))*A; n=n+1; PAM2bit8(n)=bin2dec(map8bit(v:v,7:8))*A; n=n+1; v=v+1; end PAM2bit8=PAM2bit8'; PAM2bit4=PAM2bit4'; 3- next I created 4-PAM modulator. the script name: project3_4PAM
clc A=0.1034; PAM4bit8=1:1:262144*2; PAM4bit4=1:1:262144; m=1; n=1; v=1; while v~=262145; PAM4bit4(m)=bin2dec(map4bit(v:v,:))*A; m=m+1; PAM4bit8(n)=bin2dec(map8bit(v:v,1:4))*A; n=n+1; PAM4bit8(n)=bin2dec(map8bit(v:v,5:8))*A; n=n+1; v=v+1; end PAM4bit8=PAM4bit8'; PAM4bit4=PAM4bit4'; 4- next created 8-PAM modulator. the script name: project3_8PAM clc A=0.0067; PAM8bit8=1:1:262144; PAM8bit4=1:1:262144/2; m=1; n=1; v=1; while v~=262145; j=[map4bit(v,1),map4bit(v,2),map4bit(v,3),map4bit(v,4),map4bit(v+1,1),map4bit(v+1,2),map4bi t(v+1,3),map4bit(v+1,4)]; PAM8bit4(m)=bin2dec(j)*A; m=m+1; v=v+2;
end v=1; while v~=262145; PAM8bit8(n)=bin2dec(map8bit(v:v,:))*A; n=n+1; v=v+1; end PAM8bit8=PAM8bit8'; PAM8bit4=PAM8bit4'; 5- and finally created QPSK modulator. the script name: project3_QPSK clc A=[0.7071+0.7071i ; -0.7071+0.7071i ; 0.7071-0.7071i ; -0.7071-0.7071i]; QPSKbit8=1:1:262144*4; QPSKbit8=QPSKbit8'; QPSKbit4=1:1:262144*2; QPSKbit4=QPSKbit4'; m=1; n=1; v=1; while v~=262145; QPSKbit4(m)=A(bin2dec(map4bit(v,1:2))+1); m=m+1; QPSKbit4(m)=A(bin2dec(map4bit(v,3:4))+1); m=m+1; QPSKbit8(n)=A(bin2dec(map8bit(v,1:2))+1); n=n+1; QPSKbit8(n)=A(bin2dec(map8bit(v,3:4))+1); n=n+1; QPSKbit8(n)=A(bin2dec(map8bit(v,5:6))+1); n=n+1; QPSKbit8(n)=A(bin2dec(map8bit(v,7:8))+1); n=n+1; v=v+1; end
Q2. in this part of project I created receiver demodulator for each of 2-PAM, 4-PAM, 8-PAM and QPSK. 1- 2-PAM demodulator : project3_2PAM_demod clc %project3_noise; clc A=0.44721; c=[0 ; 0 ; 0 ; 1 ; 2 ;3 ; 3 ; 3 ;3 ;3 ;3 ;3 ;3]; c=dec2bin(c); r4=PAM2bit4+n2PAM4'; r8=PAM2bit8+n2PAM8'; r4=round(r4/A); r8=round(r8/A); dePAM2bit8=dec2bin([]); dePAM2bit4=dec2bin([]); m=1; n=1; v=1; while v~=262145; dePAM2bit4(v:v,1:2)=c(r4(m)+3:r4(m)+3,1:2); dePAM2bit4(v:v,3:4)=c(r4(m+1)+3:r4(m+1)+3,1:2); m=m+2; v=v+1; end v=1; while v~=262145; dePAM2bit8(v:v,1:2)=c(r8(n)+3:r8(n)+3,1:2); dePAM2bit8(v:v,3:4)=c(r8(n+1)+3:r8(n+1)+3,1:2); dePAM2bit8(v:v,5:6)=c(r8(n+2)+3:r8(n+2)+3,1:2); dePAM2bit8(v:v,7:8)=c(r8(n+3)+3:r8(n+3)+3,1:2); n=n+4; v=v+1;
end 2- 4-PAM demodulator : project3_4PAM_demod clc A=0.1034; %project3_noise; clc c=-1:1:30; c(1)=0; c(18:32)=15; c=dec2bin(c); r4=PAM4bit4+n4PAM4'; r8=PAM4bit8+n4PAM8'; r4=round(r4/A); r8=round(r8/A); dePAM4bit8=dec2bin([]); dePAM4bit4=dec2bin([]); m=1; n=1; v=1; while v~=262145; dePAM4bit4(v:v,:)=c(r4(m)+2:r4(m)+2,:); m=m+1; v=v+1; end v=1; while v~=262145; dePAM4bit8(v:v,1:4)=c(r8(n)+2:r8(n)+2,:); dePAM4bit8(v:v,5:8)=c(r8(n+1)+2:r8(n+1)+2,:); n=n+2;
v=v+1; end 3- 8-PAM demodulator : project3_8PAM_demod clc A=0.0067; %project3_noise; clc c=-1:1:4000; c(1)=0; c(258:4002)=255; c=dec2bin(c); r4=PAM8bit4+n8PAM4'; r8=PAM8bit8+n8PAM8'; r4=round(r4/A); r8=round(r8/A); dePAM8bit8=dec2bin([]); dePAM8bit4=dec2bin([]); m=1; n=1; v=1; while v~=262146/2; dePAM8bit4(m:m,1:4)=c(r4(v)+2:r4(v)+2,1:4); m=m+1; dePAM8bit4(m:m,1:4)=c(r4(v)+2:r4(v)+2,5:8); m=m+1; v=v+1; end v=1; while v~=262145;
dePAM8bit8(v:v,:)=c(r8(n)+2:r8(n)+2,:); n=n+1; v=v+1; end 4- QPSK demodulator : project3_deQPSK clc %project3_nois; clc r4=QPSKbit4+nQPSK4'; r8=QPSKbit8+nQPSK8'; % received signal with 4 bit quantized. % received signal with 8 bit quantized. r4=round(r4*(2^.5)); % round the received signal (make a decision) r8=round(r8*(2^.5)); % round the received signal (make a decision) deQPSK4=dec2bin([]); % create empty matrix to save the results of demodulator deQPSK8=dec2bin([]); % create empty matrix to save the results of demodulator c1=[ 0 0 1 1 1 1 1 1]; % demodulate table c1=dec2bin(c1); c2=[ 0 0 1 1 1 1 1 1]; % demodulate table c2=dec2bin(c2); m=1; n=1; v=1; while v~=262145; deQPSK4(v:v,1)=c1(real(r4(m))+3); % demodulate the imaginary part using the demodulator table deQPSK4(v:v,2)=c2(imag(r4(m))+3); % demodulate the real part using the demodulator table m=m+1; deQPSK4(v:v,3)=c1(real(r4(m))+3); % demodulate the imaginary part using the demodulator table deQPSK4(v:v,4)=c2(imag(r4(m))+3); % demodulate the real part using the demodulator table m=m+1;
deQPSK8(v:v,1)=c1(imag(r8(n))+3); % demodulate the imaginary part using the demodulator table deQPSK8(v:v,2)=c2(real(r8(n))+3); % demodulate the real part using the demodulator table n=n+1; deQPSK8(v:v,3)=c1(imag(r8(n))+3); % demodulate the imaginary part using the demodulator table deQPSK8(v:v,4)=c2(real(r8(n))+3); % demodulate the real part using the demodulator table n=n+1; deQPSK8(v:v,5)=c1(imag(r8(n))+3); % demodulate the imaginary part using the demodulator table deQPSK8(v:v,6)=c2(real(r8(n))+3); % demodulate the real part using the demodulator table n=n+1; deQPSK8(v:v,7)=c1(imag(r8(n))+3); % demodulate the imaginary part using the demodulator table deQPSK8(v:v,8)=c2(real(r8(n))+3); % demodulate the real part using the demodulator table n=n+1; v=v+1; end Q3 + Q4 1- first I created script to calculate the actual BER the script name : project3_BER clc vi = 1.6:-.1:.1; ui=1; t1=1:1:16; t2=1:1:16; t3=1:1:16; t4=1:1:16; t5=1:1:16; t6=1:1:16; t7=1:1:16; t8=1:1:16; %noise for 2PAM while ui~=17;
分享到:
收藏