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

📄 sconvenc.m

📁 Proakis《contemporarycommunication systems using matlab》matlab源代码
💻 M
字号:
function [sys, x0, str, ts] = sconvenc(t, x, u, flag, tran_func);
%SVITERBI SIMULINK file for convolution encoding.
%       This file is designed to be used in a SIMULINK S-Function block.
%       The function requires the system inputs
%       tran_func  is one of the two forms of convolution code transfer function.
%

%       Wes Wang
%       Copyright (c) 1995-96 by The MathWorks, Inc.

if (flag == 2) % refresh discrete-time states
  % the major processing routine.
  if u(length(u)) < .2
    % in the case of no signal, no processing.
    return;
  end;

  % otherwise, there is a signal, have to process.

  % initial parameters.
  [A, B, C, D, N, K, M] = gen2abcd(tran_func);
  u = u(1:K);
  if isempty(C)
    sys = zeros(M, 1);
    msg_i = bi2de(u(:)');
%    tran_indx = x(1) + 1 + msg_i * 2^K;
    tran_indx = x(1) + 1 + msg_i * 2^M;
    sys(1) = tran_func(tran_indx+2, 1);
  else
    x = x(:); u = u(:);
    sys = A * x + B * u;
    sys = rem(sys, 2);
  end;
elseif flag == 3 % output
  if u(length(u)) < .2
    % in the case of no signal, no processing.
    return;
  end;

  % otherwise, there is a signal, have to process.
  % initial parameters.
  [A, B, C, D, N, K, M] = gen2abcd(tran_func);
  u = u(1:K);
  if isempty(C)
    msg_i = bi2de(u(:)');
%    tran_indx = x(1) + 1 + msg_i * 2^K;
    tran_indx = x(1) + 1 + msg_i * 2^M;
    sys = B(tran_indx, :)';
  else
    x = x(:); u = u(:);
    sys = C * x + D * u;
    sys = rem(sys, 2);
  end;
elseif flag == 0
  [A, B, C, D, N, K, M] = gen2abcd(tran_func);
  x0 = zeros(M, 1);
  sys = [0; length(x0); N; K+1; 0; 0; 1];
  ts = [-1, 0];
else
  sys = [];
end;

⌨️ 快捷键说明

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