通信原理研究型学习报告.docx
《通信原理研究型学习报告.docx》由会员分享,可在线阅读,更多相关《通信原理研究型学习报告.docx(49页珍藏版)》请在冰豆网上搜索。
通信原理研究型学习报告
通信原理
设置目的:
检验学生对基带调制知识点的理解,掌握和运用程度,锻炼其分析问题,开展研究的能力。
内容要求:
PCM,LPCM编译码仿真分析,
仿真实现A律13折线编译码,比较理论以及实际量化信噪比,信号源自定(包括语音信号的编译码)。
仿真结果:
假定抽样值Sa=150
(1)实现LPCM
正极性编码第一位为1,负极性第一位编码为0。
理论信噪比采用SNR=3*M^2/Kcr^2,其中Kcr=x/(x/sqrt
(2));实际信噪比SN=S/N,其中S=sum(yk.^2,Sa+1)/(Sa+1)
N=sum((yk-deyk).^2,Sa+1)/(Sa+1),抽样点数越多,越接近理论量化信噪比。
对yt=cos(2000*t)进行抽样,抽样频率为fs=8000Hz,量化间隔delta=1/2^7。
信噪比:
理论值SNR=43.9051dB,实际值SN=44.4416dB
.m程序如下:
t=0:
0.01:
2*pi
x=1
yt=x*cos(2000*t)
M=2^7
delta=x/M
fs=8000
Ts=1/fs
Sa=150
ks=0:
Sa
yk=x*cos(ks*Ts*2000)
code=zeros(1,8)
CODE=zeros(Sa+1,8)
fork=0:
Sa
ifyk(k+1)>=0
code
(1)=1
i=2
a=floor(yk(k+1)/delta)
ifa<1
code=[1zeros(1,7)]
elseifa==128
code=[1,ones(1,7)]
elseifa>1
while(a~=0)
code(8+2-i)=mod(a,2)
a=floor(a/2)
i=i+1
end
end
elseifyk(k+1)<0
code
(1)=0
i=2
a=ceil(yk(k+1)/delta)
ifa>-1
code=[0zeros(1,7)]
elseifa==-128
code=[0,ones(1,7)]
elseifa<-1
while(a~=0)
code(8+2-i)=mod(a,2)
a=ceil(a/2)
i=i+1
end
end
end
fori=1:
8
CODE(k+1,i)=code(i)
end
code=zeros(1,8)
end
decode=zeros(1,8)
deyk=double(zeros(1,Sa+1))
fork=0:
Sa
fori=1:
8
decode(i)=CODE(k+1,i)
end
ifdecode
(1)==1
deyk(k+1)=(decode
(2)*2^6+decode(3)*2^5+decode(4)*2^4+decode(5)*2^3+decode(6)*2^2+decode(7)*2^1+decode(8)*2^0+0.5)*delta
elseifdecode
(1)==0
deyk(k+1)=-(decode
(2)*2^6+decode(3)*2^5+decode(4)*2^4+decode(5)*2^3+decode(6)*2^2+decode(7)*2^1+decode(8)*2^0+0.5)*delta
end
end
plot(ks,yk,'r',ks,deyk,'b')
figure
plot(ks,yk-deyk)
display(CODE)
Kcr=x/(x/sqrt
(2))
SNR=10*log10(3*M^2/Kcr^2)
S=sum(yk.^2,Sa+1)/(Sa+1)
N=sum((yk-deyk).^2,Sa+1)/(Sa+1)
SN=10*log10(S/N)
display(SNR)
display(SN)
编译码图形
(红色是原码,蓝色的是译码之后的)差别较小,可以放大来看。
放大:
误差:
(2)A率13折线编译码:
输入信号为yt=cos(2000*t),正域值为极性值1,负域为0.理论信噪比采用分段求量化噪声,再求出总的量化噪声,进而得出量化信噪比。
实际信噪比SN=vpa(Sq/N)其中,Sq=sum(yk.^2,Sa+1)/(Sa+1),N=sum((deyk-yk).^2,Sa+1)/(Sa+1)抽样频率f=8000Hz,最小量化间隔delta=1/2^11
信噪比:
理论值SNR=4607.437569,实际值SN=4658.422888。
抽样值越大,实际信噪比越接近理论值。
.m程序实现:
t=0:
0.01:
2*pi
x=1
yt=x*cos(2000*t)
M=2^11
delta=x/M
d1=delta
d2=delta
d3=2*delta
d4=4*delta
d5=8*delta
d6=16*delta
d7=32*delta
d8=64*delta
fs=8000
Ts=1/fs
Sa=150
ks=0:
Sa
yk=x*cos(ks*Ts*2000)
code=zeros(1,8)
CODE=zeros(Sa+1,8)
fork=0:
Sa
ifyk(k+1)>=0
code
(1)=1
elseifyk(k+1)<0
code
(1)=0
end
if0*x<=abs(yk(k+1))&abs(yk(k+1))<1/128*x
code
(2)=0
code(3)=0
code(4)=0
a=floor(abs(yk(k+1))/d1)
ifa<1
code(5)=0
code(6)=0
code(7)=0
code(8)=0
elseif16>a>=1
i=0
while(a~=0)
code(8-i)=mod(a,2)
a=floor(a/2)
i=i+1
end
elseifa==16
code=[10001111]
end
elseif1/128*x<=abs(yk(k+1))&abs(yk(k+1))<1/64*x
code
(2)=0
code(3)=0
code(4)=1
a=floor((abs(yk(k+1))-16*delta)/d2)
ifa<1
code(5)=0
code(6)=0
code(7)=0
code(8)=0
elseif16>a>=1
i=0
while(a~=0)
code(8-i)=mod(a,2)
a=floor(a/2)
i=i+1
end
elseifa==16
code=[10011111]
end
elseif1/64*x<=abs(yk(k+1))&abs(yk(k+1))<1/32*x
code
(2)=0
code(3)=1
code(4)=0
a=floor((abs(yk(k+1))-32*delta)/d3)
ifa<1
code(5)=0
code(6)=0
code(7)=0
code(8)=0
elseif16>a>=1
i=0
while(a~=0)
code(8-i)=mod(a,2)
a=floor(a/2)
i=i+1
end
elseifa==16
code=[10101111]
end
elseif1/32*x<=abs(yk(k+1))&abs(yk(k+1))<1/16*x
code
(2)=0
code(3)=1
code(4)=1
a=floor((abs(yk(k+1))-64*delta)/d4)
ifa<1
code(5)=0
code(6)=0
code(7)=0
code(8)=0
elseif16>a>=1
i=0
while(a~=0)
code(8-i)=mod(a,2)
a=floor(a/2)
i=i+1
end
elseifa==16
code=[10111111]
end
elseif1/16*x<=abs(yk(k+1))&abs(yk(k+1))<1/8*x
code
(2)=1
code(3)=0
code(4)=0
a=floor((abs(yk(k+1))-128*delta)/d5)
ifa<1
code(5)=0
code(6)=0
code(7)=0
code(8)=0
elseif16>a>=1
i=0
while(a~=0)
code(8-i)=mod(a,2)
a=floor(a/2)
i=i+1
end
elseifa==16
code=[11001111]
end
elseif1/8*x<=abs(yk(k+1))&abs(yk(k+1))<1/4*x
code
(2)=1
code(3)=0
code(4)=1
a=floor((abs(yk(k+1))-256*delta)/d6)
ifa<1
code(5)=0
code(6)=0
code(7)=0
code(8)=0
elseif16>a>=1
i=0
while(a~=0)
code(8-i)=mod(a,2)
a=floor(a/2)
i=i+1
end
elseifa==16
code=[11011111]
end
elseif1/4*x<=abs(yk(k+1))&abs(yk(k+1))<1/2*x
code
(2)=1
code(3)=1
code(4)=0
a=floor((abs(yk(k+1))-512*delta)/d7)
ifa<1
code(5)=0
code(6)=0
code(7)=0
code(8)=0
elseif16>a>=1
i=0
while(a~=0)
code(8-i)=mod(a,2)
a=floor(a/2)
i=i+1
end
elseifa==16
code=[11101111]
end
elseif1/2*x<=abs(yk(k+1))&abs(yk(k+1))<=x
code
(2)=1
code(3)=1
code(4)=1
a=floor((abs(yk(k+1))-1024*delta)/d8)
ifa<1
code(5)=0
code(6)=0
code(7)=0
code(8)=0
elseif16>a>=1
i=0
while(a~=0)
code(8-i)=mod(a,2)
a=floor(a/2)
i=i+1
end
elseifa==16
code=[11111111]
end
end
fori=1:
8
CODE(k+1,i)=code(i)
end
code=zeros(1,8)
end
decode=zeros(1,8)
deyk=double(zeros(1,Sa+1))
fork=0:
Sa
fori=1:
8
decode(i)=CODE(k+1,i)
end
ifdecode
(1)==1
ifdecode
(2)==0&decode(3)==0&decode(4)==0
deyk(k+1)=(decode(5)*2^3+decode(6)*2^2+decode(7)*2^1+decode(8)*2^0+0.5)*d1
elseifdecode
(2)==0&decode(3)==0&decode(4)==1
deyk(k+1)=16*delta+(decode(5)*2^3+decode(6)*2^2+decode(7)*2^1+decode(8)*2^0+0.5)*d2
elseifdecode
(2)==0&decode(3)==1&decode(4)==0
deyk(k+1)=32*delta+(decode(5)*2^3+decode(6)*2^2+decode(7)*2^1+decode(8)*2^0+0.5)*d3
elseifdecode
(2)==0&decode(3)==1&decode(4)==1
deyk(k+1)=64*delta+(decode(5)*2^3+decode(6)*2^2+decode(7)*2^1+decode(8)*2^0+0.5)*d4
elseifdecode
(2)==1&decode(3)==0&decode(4)==0
deyk(k+1)=128*delta+(decode(5)*2^3+decode(6)*2^2+decode(7)*2^1+decode(8)*2^0+0.5)*d5
elseifdecode
(2)==1&decode(3)==0&decode(4)==1
deyk(k+1)=256*delta+(decode(5)*2^3+decode(6)*2^2+decode(7)*2^1+decode(8)*2^0+0.5)*d6
elseifdecode
(2)==1&decode(3)==1&decode(4)==0
deyk(k+1)=512*delta+(decode(5)*2^3+decode(6)*2^2+decode(7)*2^1+decode(8)*2^0+0.5)*d7
elseifdecode
(2)==1&decode(3)==1&decode(4)==1
deyk(k+1)=1024*delta+(decode(5)*2^3+decode(6)*2^2+decode(7)*2^1+decode(8)*2^0+0.5)*d8
end
elseifdecode
(1)==0
ifdecode
(2)==0&decode(3)==0&decode(4)==0
deyk(k+1)=-(decode(5)*2^3+decode(6)*2^2+decode(7)*2^1+decode(8)*2^0+0.5)*d1
elseifdecode
(2)==0&decode(3)==0&decode(4)==1
deyk(k+1)=-(16*delta+(decode(5)*2^3+decode(6)*2^2+decode(7)*2^1+decode(8)*2^0+0.5)*d2)
elseifdecode
(2)==0&decode(3)==1&decode(4)==0
deyk(k+1)=-(32*delta+(decode(5)*2^3+decode(6)*2^2+decode(7)*2^1+decode(8)*2^0+0.5)*d3)
elseifdecode
(2)==0&decode(3)==1&decode(4)==1
deyk(k+1)=-(64*delta+(decode(5)*2^3+decode(6)*2^2+decode(7)*2^1+decode(8)*2^0+0.5)*d4)
elseifdecode
(2)==1&decode(3)==0&decode(4)==0
deyk(k+1)=-(128*delta+(decode(5)*2^3+decode(6)*2^2+decode(7)*2^1+decode(8)*2^0+0.5)*d5)
elseifdecode
(2)==1&decode(3)==0&decode(4)==1
deyk(k+1)=-(256*delta+(decode(5)*2^3+decode(6)*2^2+decode(7)*2^1+decode(8)*2^0+0.5)*d6)
elseifdecode
(2)==1&decode(3)==1&decode(4)==0
deyk(k+1)=-(512*delta+(decode(5)*2^3+decode(6)*2^2+decode(7)*2^1+decode(8)*2^0+0.5)*d7)
elseifdecode
(2)==1&decode(3)==1&decode(4)==1
deyk(k+1)=-(1024*delta+(decode(5)*2^3+decode(6)*2^2+decode(7)*2^1+decode(8)*2^0+0.5)*d8)
end
end
end
plot(ks,yk,'-r*',ks,deyk,'--bd')
figure
plot(ks,deyk-yk)
display(CODE)
S=x^2/2
symse
Nq1=1/d1*int(e^2,-d1/2,d1/2)
Nq2=1/d2*int(e^2,-d2/2,d2/2)
Nq3=1/d3*int(e^2,-d3/2,d3/2)
Nq4=1/d4*int(e^2,-d4/2,d4/2)
Nq5=1/d5*int(e^2,-d5/2,d5/2)
Nq6=1/d6*int(e^2,-d6/2,d6/2)
Nq7=1/d7*int(e^2,-d7/2,d7/2)
Nq8=1/d8*int(e^2,-d8/2,d8/2)
Nq=Nq1+Nq2+Nq3+Nq4+Nq5+Nq6+Nq7+Nq8
digits(10)
SNR=10*log10(vpa(S/Nq))
Sq=sum(yk.^2,Sa+1)/(Sa+1)
N=sum((deyk-yk).^2,Sa+1)/(Sa+1)
SN=10*log10(vpa(Sq/N))
display(SNR)
display(SN)
编译码图形
(红色是原码,蓝色的是译码之后的)差别较小,可以放大来看。
放大:
误差:
(3)语音信号的编译码:
实现读入一段语音信号,然后编码译码。
由于对于语音信号的处理计算量很大,所以只录了一小段音频,如果要运行这个程序,注意更改音频文件的路径。
1)
语音信号的PCM编译码的原图复原图:
(蓝色的为原图,红色的为复原图)
语音信号的PCM编译码的误差图
程序如下:
y=wavread('d:
\我的文档\桌面\Sclip',[115200])
yk=y'
x=max(abs(yk))
M=2^11
delta=x/M
d1=delta
d2=delta
d3=2*delta
d4=4*delta
d5=8*delta
d6=16*delta
d7=32*delta
d8=64*delta
Sa=length(yk)
ks=1:
Sa
code=zeros(1,8)
decode=zeros(1,8)
deyk=double(zeros(1,Sa))
fork=1:
Sa
ifyk(k)>=0
code
(1)=1
elseifyk(k)<0
code
(1)=0
end
if0*x<=abs(yk(k))&abs(yk(k))<1/128*x
code
(2)=0
code(3)=0
code(4)=0
a=floor(abs(yk(k))/d1)
ifa<1
code(5)=0
code(6)=0
code(7)=0
code(8)=0
elseif16>a>=1
i=0
while(a~=0)
code(8-i)=mod(a,2)
a=floor(a/2)
i=i+1
end
elseifa==16
code=[10001111]
end
elseif1/128*x<=abs(yk(k))&abs(yk(k))<1/64*x
code
(2)=0
code(3)=0
code(4)=1
a=floor((abs(yk(k))-16*delta)/d2)
ifa<1
code(5)=0
code(6)=0
code(7)=0
code(8)=0
elseif16>a>=1
i=0
while(a~=0)
code(8-i)=mod(a,2)
a=floor(a/2)
i=i+1
end
elseifa==16
code=[10011111]
end
elseif1/64*x<=abs(yk(k))&abs(yk(k))<1/32*x
code
(2)=0
code(3)=1
code(4)=0
a=floor((abs(yk(k))-32*delta)/d3)
ifa<1
code(5)=0
code(6)=0
code(7)=0
code(8)=0
elseif16>a>=1
i=0
while(a~=0)
code(8-i)=mod(a,2)
a=floor(a/2)
i=i+1
end
elseifa==16
code=[10101111]
end
elseif1/32*x<=abs(yk(k))&abs(yk(k))<1/16*x
code
(2)=0
code(3)=1
code(4)=1
a=floor((abs(yk(k))-64*delta)/d4)
ifa<1
code(5)=0
code(6)=0
code(7)=0
code(8)=0
elseif16>a>=1
i=0
while(a~=0)
code(8-i)=mod(a,2)
a=floor(a/2)
i=i+1
end
elseifa==16
code=[10111111]
end
elseif1/16*x<=abs(yk(k))&abs(yk(k))<1/8*x
code
(2)=1
code(3)=0
code(4)=0
a=floor((abs(yk(k))-128*delta)/d5)
ifa<1
code(5)=0
code(6)=0
code(7)=0
code(8)=0
elseif16>a>=1
i=0
while(a~=0)
code(8-i)=mod(a,2)
a=floor(a/2)
i=i+1
end
elseifa==16
code=[11001111]
end
elseif1/8*x<=abs(yk(k))&abs(yk(k))<1/4*x
code
(2)=1
code(3)=0
code(4)=1
a=floor((abs(yk(k))-256*delta)/d6)
ifa<1
code(5)=0