lzparse.m

来自「matlab 通信仿真。好」· M 代码 · 共 28 行

M
28
字号
% This m-file is called LZparse.m
%It accomplishes Lempel-Ziv parsingof a binary datavector
% x is a binary datavector.
% y=LZparse(x) is a vector consisting of the indices of the 
% blocks in the Lempel-Ziv parsing of x.

function y=LZparse(x)
N=length(x);
dict=[];
lengthdict=0;
while lengthdict<N
    i=lengthdict+1;
    k=0;
    while k==0
        v=x(lengthdict+1:i);
        j=bitstring_to_index(v);
        A=(dict~=j);
        k=prod(real(A));
        if i==N
            k=1;
        else
        end
        i=i+1;
    end
    dict=[dict j];
    lengthdict=lengthdict+length(v);
end
y=dict;

⌨️ 快捷键说明

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