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

📄 trigfmfl.m

📁 数字通信第四版原书的例程
💻 M
字号:
function [sys,x0] = trigfmfl(t,x,u,flag,num_pulse,yin,...
                       init_out, init_state, threshold)
%TRIGWKSP reads a data or a character from workspace by counting the
%        number of triggers. Different from the time driven from
%        workspace block, this is a event driven block.
%        YIN: data to be read in. block output size is the column of
%             this block. The block outputs a row of the data each
%             time. The data is 

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

if flag == 2     %refresh states
      sys = x;
        sys(2) = u;
     % the state will be changed only under the following condition
  if (x(2) <= threshold) & (u > threshold)
                if sys(3) == 0
                  xlength = length(x);
                    resid = 5:length(x);
                    %refresh the output
                     sys(1) = sys(1) + 1;
                    if sys(1) <= sys(4)
                             if isstr(yin)
                                   sys(resid) = abs(yin(sys(1),:));
                                else
                                    sys(resid) = yin(sys(1),:);
                             end;
                    else
                            sys(resid) = 0 * sys(resid);
                    end;
            end;
            sys(3) = rem(sys(3)+1, num_pulse);
      end;
elseif flag == 3 %output calculation
        sys = x(5:length(x));
elseif flag == 0 %initial condition
        [n,m]=size(yin);
        if isempty(n) | isempty(m)
              n=0;
            m=0;
            [x,y]=get_param;
                x = [x '/' y];
          disp(['There is nothing in the triggered workspace block ',x]);
 end;
        sys = [0;4+m;m;1;0;0];
      if isempty(init_state)
          init_state = 0; 
        end;
    if isempty(init_out)
            init_out = zeros(1,m);   
       elseif length(init_out ~= m)
            init_out = ones(1,m) * init_out(1);
     else
            tmp=zeros(1,m);
         tmp(:) = init_out(:);
   end;
        x0 = [0,init_state,0,n,init_out];
   % x0 = [position_in_yin, last_input_value, pulse_number_counting,...
    %        size_of_yin, output_value]
else         %all of the other cases.
        sys = [];
       % if flag == 4, sys = []; means this block has to be called at 
 % every time-hit
end;

⌨️ 快捷键说明

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