⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qcoeff.m

📁 Digital Signal Processing with MATLAB是Proakis於DSP的經點著作 內涵此書的source code
💻 M
字号:
function [y,L,B] = QCoeff(x,N)
%  [y,L,B] = QCoeff(x,N)
%      Coefficient Quantization using N=L+B bit Representation
%        with Rounding operation
%      y: quantized array (same dim as x)
%      L: number of integer bits 
%      B: number of fractional bits
%      x: a scalar, vector, or matrix
%      N: total number of bits

xm = abs(x);
 L = max(max(0,fix(log2(xm(:)+eps)+1))); % Integer bits
if (L > N)
     errmsg = [' *** N must be at least ',num2str(L),' ***'];
     error(errmsg);
end 
B = N-L;                            % Fractional bits
y = xm./(2^L); y = round(y.*(2^N)); % Rounding to N bits
y = sign(x).*y*(2^(-B));            % L+B+1 bit representation

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -