home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 10.ddi / CONTROL.DI$ / STEPFUN.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  456 b   |  22 lines

  1. function y = stepfun(t,to)
  2. %STEPFUN  Unit step function.
  3. %    STEPFUN(T,T0), where T is a monotonically increasing vector,
  4. %    returns a vector the same length as T with zeros where T < T0
  5. %    and ones where T >= T0.
  6.  
  7. %    J.N. Little 6-3-87
  8. %    Copyright (c) 1986-93 by the MathWorks, Inc.
  9.  
  10. [m,n] = size(t);
  11. y = zeros(m,n);
  12. i = find(t>=to);
  13. if isempty(i)
  14.     return
  15. end
  16. i = i(1);
  17. if m == 1
  18.     y(i:n) = ones(1,n-i+1);
  19. else
  20.     y(i:m) = ones(m-i+1,1);
  21. end
  22.