home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / PLOTXY.DI$ / STEM.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  1.1 KB  |  42 lines

  1. function stem(x,y,linetype)
  2. %STEM    Plot discrete sequence data.
  3. %    STEM(Y) plots the data sequence Y as stems from the x-axis
  4. %    terminated with circles for the data value.
  5. %    STEM(X,Y) plots the data sequence Y at the values specfied
  6. %    in X.
  7. %    There is an optional final string argument to specify a line-type
  8. %    for the stems of the data sequence.  E.g. STEM(X,Y,'-.') or
  9. %    STEM(Y,':').
  10. %
  11. %    See also PLOT, BAR, STAIRS.
  12.  
  13. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  14.  
  15. n = length(x);
  16. if nargin == 1
  17.     y = x(:)';
  18.     x = 1:n;
  19.     linetype = '-';
  20. elseif nargin == 2
  21.     if isstr(y)
  22.         linetype = y;
  23.         y = x(:)';
  24.         x = 1:n;
  25.     else
  26.         x = x(:)';
  27.         y = y(:)';
  28.         linetype = '-';
  29.     end
  30. elseif nargin == 3
  31.     x = x(:)';
  32.     y = y(:)';
  33. end
  34. xx = [x;x;nan*ones(size(x))];
  35. yy = [zeros(1,n);y;nan*ones(size(y))];
  36. cax = newplot;
  37. next = lower(get(cax,'NextPlot'));
  38. hold_state = strcmp(next,'add') & strcmp('add',lower(get(gcf,'NextPlot')));
  39. plot(x,y,'yo',xx(:),yy(:),['y' linetype])
  40. q = axis;hold on;plot([q(1) q(2)],[0 0],'w-');
  41. if ~hold_state, set(cax,'NextPlot',next); end
  42.