📄 gen2abcd.m
字号:
function [a, b, c, d, N, K, M] = gen2abcd(gen, code_param)
%GEN2ABCD Convert a convolution generate function into [A, B, C, D] form.
% [A, B, C, D] = GEN2ABCD(GEN) converts the generate function provided
% in GEN, either the binary form of output from SIM2GEN2 or the OCT form
% output from SIM2GEN into the binary state form [A, B, C, D]. The state
% form of the generating function is
% x(k+1) = A x(k) + B u(k)
% y(k) = C x(k) + D u(k)
% For the octal form GEN, the realization may not be the minimum degree
% realization.
%
% [A, B, C, D] = GEN2ABCD(TRAN_FUNC, CODE_PARAM) converts the binary
% generating function into [A, B, C, D] form. CODE_PARAM = [N, K, M],
% where N is the output codeword length and is the row number of D. K
% is the input message length and is the column number of D. M is the
% memory length. The output of this function TRAN_FUNC is a K-by-N*(M+1)
% binary matrix. TRAN_FUNC has the following form:
% | G11 G12 ... G1N |
% TRAN_FUNC = | ... |
% | GK1 GK2 ... GKN |
% where Gij is a length M row vector, which is the transfer from the Ith
% input to Jth output.
%
% [A, B, C, D, N, K, M] = GEN2ABCD(....) outputs the codeword length N,
% message length K, and memory length M.
%
% TRAN_FUNC = GEN2ABCD(...) output the input form of in the first syntex
% form.
% See also: OCT2GEN, SIM2GEN, SIM2GEN2.
% Wes Wang 12/5/95
% Copyright (c) 1995-96 by The MathWorks, Inc.
% $Revision: 1.1 $ $Date: 1996/04/01 17:57:51 $
if nargin < 1
error('Not enough input variable.')
end;
if nargin < 2
if isstr(gen)
gen = sim2tran(gen);
end;
[len_m, len_n] = size(gen);
if gen(len_m, len_n) < 0
N = gen(1, len_n);
K = gen(2, len_n);
M = gen(3, len_n);
if (M+K > len_n) | (M+N > len_m)
error('The Transfer function is invalid.');
end;
a = gen(1:M, 1:M);
b = gen(1:M, M+1:M+K);
c = gen(M+1:M+N, 1:M);
d = gen(M+1:M+N, M+1:M+K);
elseif max(max(gen)) == Inf
if nargout == 1
a = gen;
elseif nargout > 1
M = gen(2, 1);
N = gen(1, 2);
K = gen(2, 2);
a = de2bi(gen(3:len_m, 1), M);
b = de2bi(gen(3:len_m, 2), N);
c = [];
d = [];
end;
return;
else
[gen, code_param] = oct2gen(gen);
nargin = 2;
end;
end;
if nargin >= 2
N = code_param(1);
K = code_param(2);
M = code_param(3);
G = [];
for i = 1 : M+1
G = [G ; gen(:, i:M+1:N*(M+1))];
end;
a = eye(K * (M-1));
a = [zeros(K, K), zeros(K, length(a)); a, zeros(length(a), K)];
% B matrix:
b = [eye(K); zeros(length(a)-K, K)];
% C matrix
c = [];
for i = 1 : M
c = [ c, G(i*K + 1 : (i + 1) * K, :)'];
end;
% D matrix
d = G(1:K, :)';
end;
M = length(a);
end;
if nargout == 1
tran_func = [a b; c d];
[len_m, len_n] = size(tran_func);
if len_m < 4
tran_func = [tran_func; zeros(4-len_m, len_n)];
[len_m, len_n] = size(tran_func);
end;
tran_func = [tran_func zeros(len_m, 1)];
len_n = len_n + 1;
tran_func(1, len_n) = N;
tran_func(2, len_n) = K;
tran_func(3, len_n) = M;
tran_func(len_m, len_n) = -Inf;
a = tran_func;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -