rllencode.m

来自「rll(run length limited) code for channel」· M 代码 · 共 23 行

M
23
字号
%RLLencode(in)
%   This function RLL encodes a string of bits (whose length must be 
%   an integer multiple of p) into a (d,inf) RLL code that holds
%   when concatenated.

function out = RLLencode(in)

load codebook n d allwords totalwords
 
p = length(de2bi(totalwords)) - 1;
q = n + d;
rate = p/q;
chain = zeros(1,length(in) / rate);

for i=0:(length(in)/p)-1
    lookup = in(p*i+1:p*(i+1));
    index = bi2de(fliplr(lookup)) + 1;
    coded = zeros(1,q);
    coded(1:n) = allwords(index, 1:n);
    chain(q*i+1:q*(i+1)) = coded;
end

out = chain;

⌨️ 快捷键说明

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