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

📄 rld.m

📁 matlab实现的游程编码的编码与解码过程
💻 M
字号:
function [x] = rld(val,len)
% RLD   Run Length Decoding
%    X = RLD(VAL,LEN) decodes the run values, VAL, and run lengths, LEN, into
%    vector X.
%
%    Example:
%       >> VAL = [1 3 8]
%       >> LEN = [4 2 6]
%       >> X = RLD(VAL,LEN)
%    Returns:
%       VAL =
%            1     3     8
%       LEN =
%            4     2     6
%       X =
%            1     1     1     1     3     3     8     8     8     8     8     8
%
%    See also RLE.

% Steve Hoelzer
% 2003-09-04

% Error checking
if ~any(size(len)==1) | ~any(size(val)==1)
    error('len and val must be vectors.')
end
if (length(len)~=length(val))
    error('len and val vectors must be the same length.')
end

% Transpose len vector if necessary
if (size(len,2)==1)
    len = len.';
end

% Decode
i = cumsum([ 1 len ]);
k = zeros(1, i(end)-1);
k(i(1:end-1)) = 1;
x = val(cumsum(k));

⌨️ 快捷键说明

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