sim2logi.m

来自「Proakis《contemporarycommunication system」· M 代码 · 共 38 行

M
38
字号
function tran_func = sim2logi(sim_file);
%SIM2LOGIC Convert a SIMULINK block diagram to convolution code logic representation.
%       TRAN_FUNC = SIM2TRAN(SIM_FILE) reads in a SIMULINK block diagram file
%       specified in the string SIM_FILE. The function outputs TRAN_FUNC in
%       the form of
%

%       Wes Wang 12/95
%       Copyright (c) 1995-96 by The MathWorks, Inc.
%       $Revision: 1.1 $  $Date: 1996/04/01 18:03:37 $

eval(['ext = ' sim_file '(0, [], [], 0);']);
M = ext(2); %state number
N = ext(3); %ouptut number
K = ext(4); %input number
x = []; y = [];
for i = 0 : 2^K - 1
    % input index
    u = mat2str(de2bi(i, K));
    for j = 0 : 2^M - 1
        % state index
        x0 = mat2str(de2bi(j, M));
        eval(['ext = ' sim_file '(1, ' x0 ',' u ', 7);']);
        x = [x; ext'];
        eval(['ext = ' sim_file '(1, ' x0 ',' u ', 3);']);
        y = [y; ext'];
    end;
end;
if (size(x, 2) == 1) & (size(y, 2) == 1)
    tran_func = [ [Inf N]; [M K];[x y]];
elseif size(x, 2) == 1
    tran_func = [ [Inf N]; [M K];[x bi2de(y)]];
elseif size(y, 2) == 1
    tran_func = [ [Inf N]; [M K];[bi2de(x) y]];
else
    tran_func = [ [Inf N]; [M K];[bi2de(x) bi2de(y)]];
end;

⌨️ 快捷键说明

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