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

📄 bin_enc.m

📁 通信工具箱matlab例程1。包含多个matlab实用例程程序。
💻 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 + -