Main Content

このページの翻訳は最新ではありません。ここをクリックして、英語の最新版を参照してください。

deintrlv

シンボル順序の復元

構文

deintrlvd = deintrlv(data,elements)

説明

deintrlvd = deintrlv(data,elements) は、intrlv の逆関数として機能し、data の要素の元の順序を復元します。data が長さ N のベクトルまたは N 行の行列である場合、elements は、1 ~ N の整数の順序を変更する長さ N のベクトルです。この関数を関数 intrlv の逆関数として使用するには、両方の関数で同じ elements 入力を使用します。その場合、2 つの関数は関数 intrlv の後に関数 deintrlv を適用してもデータが変更されないという意味で、逆関数といえます。

以下のコードは、intrlvdeintrlv の逆関数の関係を説明しています。

% DOCINTRLV Doc examples related to interleaver functions.

% Copyright 2003-2011 The MathWorks, Inc.

%% Example under "Example: Block Interleavers"
%---------------------------------
% begindocexample blockinterleavers
st1 = 27221; st2 = 4831; % States for random number generator
n = 7; k = 4; % Parameters for Hamming code
msg = randi([0 1],k*500,1); % Data to encode
code = encode(msg,n,k,'hamming/binary'); % Encoded data
% Create a burst error that will corrupt two adjacent codewords.
errors = zeros(size(code)); errors(n-2:n+3) = [1 1 1 1 1 1];

% With Interleaving
%------------------
inter = randintrlv(code,st2); % Interleave.
inter_err = bitxor(inter,errors); % Include burst error.
deinter = randdeintrlv(inter_err,st2); % Deinterleave.
decoded = decode(deinter,n,k,'hamming/binary'); % Decode.
disp('Number of errors and error rate, with interleaving:');
[number_with,rate_with] = biterr(msg,decoded) % Error statistics

% Without Interleaving
%---------------------
code_err = bitxor(code,errors); % Include burst error.
decoded = decode(code_err,n,k,'hamming/binary'); % Decode.
disp('Number of errors and error rate, without interleaving:');
[number_without,rate_without] = biterr(msg,decoded) % Error statistics
%   enddocexample blockinterleavers


%% Example under "Effect of Delays on Recovery of
% Convolutionally Interleaved Data"
%---------------------------------
s = RandStream.create('mt19937ar', 'seed',126097);
prevStream = RandStream.setGlobalStream(s); % Seed for repeatability

% begindocexample interleaverdelays
x = randi([0 63],20,1); % Original data
nrows = 3; slope = 2; % Interleaver parameters
D = nrows*(nrows-1)*slope; % Delay of interleaver/deinterleaver pair
hInt   = comm.ConvolutionalInterleaver('NumRegisters', nrows, ...
                    'RegisterLengthStep', slope);
hDeint = comm.ConvolutionalDeinterleaver('NumRegisters', nrows, ...
                    'RegisterLengthStep', slope);

% First approach.
x_padded = [x; zeros(D,1)]; % Pad x at the end before interleaving.
a1 = step(hInt, x_padded); % Interleave padded data.

b1 = step(hDeint, a1)
% Omit input padding and the first D symbols of the recovered data and
% compare
servec1 = step(comm.ErrorRate('ReceiveDelay',D),x_padded,b1);
ser1 = servec1(1)

% Second approach.
release(hInt); release(hDeint)
a2 = step(hInt,x); % Interleave original data.
b2 = step(hDeint,a2)
% Omit the last D symbols of the original data and the first D symbols of
% the recovered data and compare.
servec2 = step(comm.ErrorRate('ReceiveDelay',D),x,b2);
ser2 = servec2(1)
%  enddocexample interleaverdelays
RandStream.setGlobalStream(prevStream);
%---------------------------------

%% Example under "Example: Convolutional Interleavers"
%---------------------------------
% begindocexample convinterleaver
x = [1:10]'; % Original data
delay = [0; 1; 2]; % Set delays of three shift registers.
hInt = comm.MultiplexedInterleaver('Delay', delay);
hDeint = comm.MultiplexedDeinterleaver('Delay', delay);
y = step(hInt,x) % Interleave.
z = step(hDeint,y) % Deinterleave.
%   enddocexample convinterleaver
%---------------------------------
y_save=y; % Save the result for later testing.

%% Example on reference page for convintrlv
%---------------------------------
s = RandStream.create('mt19937ar', 'seed',67);
prevStream = RandStream.setGlobalStream(s); % Seed for repeatability

% begindocexample convintrlv_ref
x = randi([0 1],100,1); % Original data
nrows = 5; % Use 5 shift registers
slope = 3; % Delays are 0, 3, 6, 9, and 12.
y = convintrlv(x,nrows,slope); % Interleaving using convintrlv.
delay = [0:3:12]; % Another way to express set of delays
y1 = muxintrlv(x,delay); % Interleave using muxintrlv.
isequal(y,y1)
%   enddocexample convintrlv_ref
RandStream.setGlobalStream(prevStream);
%---------------------------------

%% Example on reference page for muxdeintrlv
%---------------------------------
s = RandStream.create('mt19937ar', 'seed',123);
prevStream = RandStream.setGlobalStream(s); % Seed for repeatability
% begindocexample muxdeintrlv_ref
delay = [0 4 8 12]; % Delays in shift registers
symbols = 100; % Number of symbols to process
% Interleave random data.
intrlved = muxintrlv(randi([0 1],symbols,1),delay);

% Deinterleave some of the data, recording state for later use.
[deintrlved1,state] = muxdeintrlv(intrlved(1:symbols/2),delay);
% Deinterleave the rest of the data, using state as an input argument.
deintrlved2 = muxdeintrlv(intrlved(symbols/2+1:symbols),delay,state);

% Deinterleave all data in one step.
deintrlved = muxdeintrlv(intrlved,delay);

isequal(deintrlved,[deintrlved1; deintrlved2])
%   enddocexample muxdeintrlv_ref
RandStream.setGlobalStream(prevStream);
%---------------------------------

%%
% ==============================================
% Documentation example from
% algdeintrlv reference page
% in matlref1.xml

% begindocexample algdeintrlv
num = 16; % Power of 2
ncols = 3; % Number of columns of data to interleave
data = rand(num,ncols); % Random data to interleave
k = 3;
h = 4;
intdata = algintrlv(data,num,'takeshita-costello',k,h);
deintdata = algdeintrlv(intdata,num,'takeshita-costello',k,h);
% enddocexample algdeintrlv

%%
% ==============================================
% Documentation example from
% algintrlv reference page
% in matlref1.xml

% begindocexample algintrlv_step1
num = 10; % Integer such that num+1 is prime
ncols = 3; % Number of columns of data to interleave
data = randi([0 num-1], num, ncols); % Random data to interleave
% enddocexample algintrlv_step1

% begindocexample algintrlv_step2
pr = gfprimfd(1,'all',num+1) % Primitive polynomials of GF(num+1)
% enddocexample algintrlv_step2

% begindocexample algintrlv_step3
primel = (num+1)-pr(:,1) % Primitive elements of GF(num+1)
% enddocexample algintrlv_step3

% begindocexample algintrlv_step4
alph = primel(1); % Choose one primitive element.
intrlvd = algintrlv(data,num,'Welch-Costas',alph); % Interleave.
% enddocexample algintrlv_step4

%%
% ==============================================
% Documentation example from
% helscandeintrlv reference page
% in matlref3.xml

% begindocexample helscandeintrlv
d = helscandeintrlv(1:12,3,4,1)
% enddocexample helscandeintrlv

%%
% ==============================================
% Documentation example from
% helscanintrlv reference page
% in matlref3.xml

% begindocexample helscanintrlv
i1 = helscanintrlv(1:12,3,4,1) % Slope of diagonal is 1.
i2 = helscanintrlv(1:12,3,4,2) % Slope of diagonal is 2.
% enddocexample helscanintrlv

%%
% ==============================================
% Documentation example from
% intrlv reference page
% in matlref3.xml

% begindocexample intrlv
p = randperm(10); % Permutation vector
a = intrlv(10:10:100,p)
% enddocexample intrlv

%%
% ==============================================
% Documentation example from
% intrlv reference page
% in matlref3.xml

% begindocexample intrlv_ex2
b = intrlv([.1 .2 .3 .4 .5; .2 .4 .6 .8 1]',[2 4 3 5 1])
% enddocexample intrlv_ex2

%%
% ==============================================
% Documentation example from
% matdeintrlv reference page
% in matlref3.xml

% begindocexample matdeintrlv
Nrows = 2; Ncols = 3;
data = [1 2 3 4 5 6; 2 4 6 8 10 12]';
a = matintrlv(data,Nrows,Ncols); % Interleave.
b = matdeintrlv(a,Nrows,Ncols) % Deinterleave.
% enddocexample matdeintrlv

%%
% ==============================================
% Documentation example from
% matintrlv reference page
% in matlref3.xml

% begindocexample matintrlv
b = matintrlv([1 2 3 4 5 6; 2 4 6 8 10 12]',2,3)
% enddocexample matintrlv


出力は以下のようになります。

b =

    10    20    30    40    50    60    70    80    90   100

拡張機能

C/C++ コード生成
MATLAB® Coder™ を使用して C および C++ コードを生成します。

バージョン履歴

R2006a より前に導入

参考