www.pudn.com > communicationmatlab.rar > PULSEGEN.M


function [sys,x0] = pulsegen(t,x,u,flag,height,width,dt) 
%PULSEGEN generates perfect pulse for communication toolbox. 
 
%       Wes Wang 
%       Copyright (c) 1995-96 by The MathWorks, Inc. 
 
if flag == 2     %refresh states 
    sys(1) = rem(x(1)+1,2); 
 if (sys(1)==1) 
          sys(2) = 1; 
             sys(3) = width; 
 else 
            sys(2) = 0; 
             sys(3) = dt - width; 
    end; 
elseif flag == 3 %output calculation 
        sys = x(2); 
elseif flag == 4 % 
   sys = t + x(3); 
elseif flag == 0 %initial condition 
      sys = [0;3;1;0;0;1]; 
    x0 = [0,0,width]; %phase, pulse value, dt; 
      if dt