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

  1. function feather(x,y,s)
  2. %FEATHER Feather plot.
  3. %    FEATHER(Z) draws a graph that displays the angle and magnitude
  4. %    of the complex elements of Z as arrows emanating from equally
  5. %    spaced points along a horizontal axis.
  6. %
  7. %    FEATHER(X,Y) is equivalent to FEATHER(X+i*Y).  It displays the
  8. %    feather plot for the angles and magnitudes of the elements of
  9. %    matrices X and Y.
  10. %
  11. %    FEATHER(Z,'S') and FEATHER(X,Y,'S') use line style 'S' where
  12. %    'S' is any legal linetype as described under the PLOT command.
  13. %
  14. %    See also COMPASS, ROSE, QUIVER.
  15.  
  16. %    Charles R. Denham, MathWorks 3-20-89
  17. %    Modified 1-2-92, ls.
  18. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  19.  
  20. if isstr(x)
  21.     error('First argument must be numeric.');
  22. end
  23. xx = [0 1 .8 1 .8]';
  24. yy = [0 0 .08 0 -.08].';
  25. arrow = xx + yy.*sqrt(-1);
  26.  
  27. if nargin == 2
  28.    if isstr(y)
  29.       s = y;
  30.       y = imag(x); x = real(x);
  31.    else
  32.       s = 'r-';
  33.    end
  34.   elseif nargin == 1
  35.    s = 'r-';
  36.    y = imag(x); x = real(x);
  37. end
  38. if isstr(x) | isstr(y)
  39.     error('First 1 or 2 numeric arguments must be numeric.')
  40. end
  41. [st,co] = colstyle(s);
  42.  
  43. x = x(:);
  44. y = y(:);
  45. if length(x) ~= length(y)
  46.    error('X and Y must be the same length.');
  47. end
  48. [m,n] = size(x);
  49.  
  50. z = (x + y.*sqrt(-1)).';
  51. a = arrow * z + ones(5,1)*(1:m);
  52. mx = max(max(abs(a)));
  53.  
  54. % Plot the feather
  55. plot(real(a), imag(a), s, [1 m], [0 0], s);
  56. if strcmp('auto',axis('state'))
  57.     axis([0 mx [-mx mx]*.3]);
  58. end
  59.  
  60.