m(a,n,mu)%MULA_PCM?mu-lawPCMencodingofasequence%?[SQNR,A_QUAN,CODE]=MULA_PCM(A,N,MU).%?a=inputsequence.%?n=numberofquantizationlevels(even).%?sqnr=outputSQNR(indB).% a_quan=quantizedoutputbeforeencoding.% code=theencodedoutput.[y,maximum]=mulaw(a,mu);[sqnr,y_q,code]=u_pcm(y,n);a_quan=invmulaw(y_q,mu);a_quan=maximum*a_quan;sqnr=20*log10(norm(a)/norm(a-a_quan));主程序:令向量a是按N(0,1)产生的长度为500的向量,即a=randn(1,500)pcm3.ma=randn(1,500);[sqnr16,a_quan16,code16]=mula_pcm(a,16,255);[sqnr64,a_quan64,code64]=mula_pcm(a,64,255);[sqnr128,a_quan128,code128]=mula_pcm(a,128,255);[Y,I]=sort(a);sqnr16sqnr64sqnr128实验分析:(1)(2)a_quan64_result=-0.4331-1.69310.11810.2756-1.1419code64_result=Columns1through1701101000101010000Columns18through301100011010001(3)sqnr16=13.5210sqnr64=25.4650sqnr128=31.7463每次实验结果有差异!随即产生实验总结: