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

  1. function [cout, hand] = contour(arg1, arg2, arg3, arg4, arg5);
  2. % CONTOUR Contour plot.
  3. %     CONTOUR(Z) is a contour plot of matrix Z treating the values in Z
  4. %     as heights above a plane.
  5. %     CONTOUR(X,Y,Z), where X and Y are vectors, specifies the X- and Y-
  6. %     axes used on the plot.
  7. %     CONTOUR(Z,N) and CONTOUR(X,Y,Z,N) draw N contour lines, 
  8. %     overriding the default automatic value.
  9. %     CONTOUR(Z,V) and CONTOURC(X,Y,Z,V) draw LENGTH(V) contour lines 
  10. %     at the values specified in vector V.
  11. %     CONTOUR(...,'linetype') draws with the color and linetype specified,
  12. %     as in the PLOT command.
  13. %
  14. %    C = CONTOUR(...) returns contour matrix C as described in CONTOURC
  15. %    and used by CLABEL.
  16. %    [C,H] = CONTOUR(...) returns a column vector H of handles to LINE
  17. %    objects, one handle per line. 
  18. %     
  19. %     See also CLABEL, CONTOURC, CONTOUR3, GRADIENT, QUIVER, PRISM.
  20.  
  21. %-------------------------------
  22. %    Additional details:
  23. %
  24. %    If the NextPLot axis property is REPLACE (HOLD is off), CONTOUR resets 
  25. %    all axis properties, except Position, to their default values
  26. %    and deletes all axis children (line, patch, surf, image, and 
  27. %    text objects).
  28.  
  29. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  30.  
  31. if nargin < 1
  32.         error('Not enough input arguments.')
  33. end
  34. % check up front for 3.5 parsing and exchange for 4.0 order
  35. if nargin >= 4
  36.         if  min(size(arg3)) == 1        % must be 3.5 syntax
  37.                 t = arg1;
  38.                 arg1 = arg3;
  39.                 arg3 = t;
  40.                 t = arg4;
  41.                 arg4 = arg2;
  42.                 arg2 = t;
  43.                 clear t
  44.         end
  45. end
  46.  
  47. cax = newplot;
  48. next = lower(get(cax,'NextPlot'));
  49. hold_state = ishold;
  50. the_passed_args = ['arg1'];
  51. for i = 2:nargin
  52.         the_passed_args = [the_passed_args, ', arg', num2str(i)];
  53. end
  54. numargs = nargin;
  55. last_arg = eval(['arg',num2str(numargs)]);
  56. if(isstr(last_arg))
  57.     numargs = numargs - 1;
  58. end
  59.  
  60. if numargs > 2
  61.         % if arg1 and arg2 are not vectors, make them vectors
  62.         if min(size(arg1)) > 1
  63.                 arg1 = arg1(1,:);
  64.         end
  65.         if min(size(arg2)) > 1
  66.                 arg2 = arg2(:,1);
  67.         end
  68.     lims = [min(min(arg1)) max(max(arg1)) min(min(arg2)) max(max(arg2))];
  69. else
  70.     [mc,nc] = size(arg1);
  71.     lims = [1 nc 1 mc];
  72. end
  73. c = []; h = [];
  74. the_call = ['[c,h] = contour3(', the_passed_args, ');'];
  75. eval(the_call);
  76. for i = 1:length(h)
  77.         zz = get(h(i),'Zdata');
  78.         set(h(i),'Zdata',zeros(size(zz)));
  79. end
  80. if ~hold_state
  81.         view(0,90);
  82.     axis(lims);
  83.     set(gca,'box','on');
  84. end
  85. if nargout > 0
  86.     cout = c;
  87.     hand = h;
  88. end
  89.