?? bin_enc.m
字號:
function [out_binary] = bin_enc(in_quantized,no_bit)
% BIN_ENC .... Natural binary source encoding of the quantization
% levels from the quantization function.
%
% BIN_ENC(Xq,N) operates on the input array Xq generated by the operation
% Xq = QUANTIZE(X,N). Thus, Xq represent the N-bit quantized
% values of the sequence X, where each quantization level is
% a decimal number in (-1,1). BIN_ENC assigns an N-bit binary
% sequence for each distinct quantization level based on its rank.
% For example, if we use 3-bits, with quantization levels at
% Q(1) = -7/8, Q(2) = -5/8, ... Q(8) = 7/8, then the output for
% the input sequence Xq = [-3/8 -5/8 1/8 7/8 -7/8] will be:
%
% MSB ..... LSB
% -------------
% 0 1 0
% 0 0 1
% 1 0 1
% 1 1 1
% 0 0 0
%
% See also BCD, BIN_DEC.
% AUTHORS : M. Zeytinoglu & N. W. Ma
% Department of Electrical & Computer Engineering
% Ryerson Polytechnic University
% Toronto, Ontario, CANADA
%
% DATE : August 1991.
% VERSION : 1.0
%===========================================================================
% Modifications history:
% ----------------------
% o Tested (and modified) under MATLAB 4.0/4.1 08.16.1993 MZ
%===========================================================================
no_sample = length(in_quantized);
out_binary = zeros(no_bit,no_sample);
%-------------------------------------------------------------------------------
% Transformation for Q(n) --> K(n) with K in {0,1,2,...,2^(N-1)}
% followed by {0,1,2,...} --> {1,2,...,2^N}.
%-------------------------------------------------------------------------------
in_integer = 2^(no_bit - 1) * (in_quantized + 1) - 0.5;
in_integer = in_integer + 1;
%-------------------------------------------------------------------------------
% Generate the look-up (N x 2^N) table
%-------------------------------------------------------------------------------
table = bcd((0:2^(no_bit)-1),no_bit);
%-------------------------------------------------------------------------------
% Determine NATURAL codes by looking up in the table "TABLE".
%-------------------------------------------------------------------------------
out_binary = table(in_integer,:);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -