1、t=0:0.1:2*pi;s=sin(t);dx=0.001;x=-1:dx:1;A=87.6;for i=1:length(x)if abs(x(i)1/A ya(i)=A*x(i)/(1+log(A);else ya(i)=sign(x(i)*(1+log(A*abs(x(i)/(1+log(A);endfigure(1)plot(x,ya,k.:);title(A)xlabel(xylabel(ygrid onhold onxx=-pi/2,asin(-7/8),asin(-6/8),asin(-5/8),asin(-4/8),asin(-3/8),asin(-2/8),asin(-1/
2、8),asin(1/8),asin(2/8),asin(3/8),asin(4/8),asin(5/8),asin(6/8),asin(7/8),pi/2yy=-1,-7/8,-6/8,-5/8,-4/8,-3/8,-2/8,-1/8,1/8,2/8,3/8,4/8,5/8,6/8,7/8,1plot(xx,yy,rstem(xx,yy,b-.legend(A律压缩特性,折线近似A律partition=-1:1/32:1;codebook=-32:1:32;index,ya,distor=quantiz(s,partition,codebook);figure(2)subplot(2,1,1)
3、;plot(t,s);subplot(2,1,2);plot(t,ya,*axis(0,7,-40,40);nu=ceil(log2(64);codebook=zeros(length(s),nu)for m=1:length(s) for j=nu:-1: if(fix(ya(m)/(2j)=1) codebook(m,nu-j)=1; ya(m)=ya(m)-2j; endcodebook3.2自编仿真实验结果 非均匀量化编码3.3自编实验结果与实验室实验结果对比分析(1)对均匀编码和非均匀编码,量化信噪比随着输入信号幅度的变化而变化;(2)在输入正弦信号幅度相同的情况下,经过A律13折线近似的PCM非均匀量化编码后的信号量化信噪比要比均匀量化编码后的信噪比小,因此,非均匀量化可以有效地改善量化信噪比。