pcm_decode.m

来自「i hope use every file i put here to evry」· M 代码 · 共 38 行

M
38
字号
function [data] = pcm_decode(code,num_array)

global H

% get BITS
s = get(H.edit20,'String');
BITS = st2de(s);
BITS = round(BITS);

%  initialize binary_array used to represent data
bin_array = de2bi(0,BITS);

% create binary_array used to represent data
for j = 2:length(num_array),
   bin_array(j,:) = de2bi(j - 1, BITS);
end

% number of blocks of N bits
blocks = length(code) / BITS;

% initialize data array
data = 0;

% initialize code index
index = 1;

for j = 1:blocks,
   
   % find decimal equivalent to binary block
   dec = bi2de(code(index:index + (BITS - 1)));
   
   % decimal number plus one represents the index of the number array
   % where the data is held
   data(j) = num_array(dec + 1);
   
   % update index
	index = index + BITS;
end

⌨️ 快捷键说明

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