Matlab实现量化过程(均匀量化)对信号进行2到8bit量化,并对两种量化方式的量化噪声作对比 clc;clear n=1:2000; y=sin(2*pi*n/100)+0.5*cos(2*pi*n/200)+2*sin(2*pi*n/300); for bits=2:8 figure(bits-1); v=0:2bits; m=-2.6+(2.6+2.6)/2bits*v; %量化 v1=1:2bits; p_round=m(v1)+(m(v1+1)-m(v1)/2; %中间值 %画原函数图 subplot(3,1,1); plot(n,y); grid on;title(y(n); axis(0,2000,-3.5,3.5); %画round()函数量化图 y_round=y; for i=1:2000 for j=1:2bits if(y(i)=m(j)&y(i)m(j+1) y_round(i)=p_round(j); end; end;