time | Calls | line |
---|
| | 1 | function h = surf(varargin)
|
| | 2 | %SURF 3-D colored surface.
|
| | 3 | % SURF(X,Y,Z,C) plots the colored parametric surface defined by
|
| | 4 | % four matrix arguments. The view point is specified by VIEW.
|
| | 5 | % The axis labels are determined by the range of X, Y and Z,
|
| | 6 | % or by the current setting of AXIS. The color scaling is determined
|
| | 7 | % by the range of C, or by the current setting of CAXIS. The scaled
|
| | 8 | % color values are used as indices into the current COLORMAP.
|
| | 9 | % The shading model is set by SHADING.
|
| | 10 | %
|
| | 11 | % SURF(X,Y,Z) uses C = Z, so color is proportional to surface height.
|
| | 12 | %
|
| | 13 | % SURF(x,y,Z) and SURF(x,y,Z,C), with two vector arguments replacing
|
| | 14 | % the first two matrix arguments, must have length(x) = n and
|
| | 15 | % length(y) = m where [m,n] = size(Z). In this case, the vertices
|
| | 16 | % of the surface patches are the triples (x(j), y(i), Z(i,j)).
|
| | 17 | % Note that x corresponds to the columns of Z and y corresponds to
|
| | 18 | % the rows.
|
| | 19 | %
|
| | 20 | % SURF(Z) and SURF(Z,C) use x = 1:n and y = 1:m. In this case,
|
| | 21 | % the height, Z, is a single-valued function, defined over a
|
| | 22 | % geometrically rectangular grid.
|
| | 23 | %
|
| | 24 | % SURF(...,'PropertyName',PropertyValue,...) sets the value of the
|
| | 25 | % specified surface property. Multiple property values can be set
|
| | 26 | % with a single statement.
|
| | 27 | %
|
| | 28 | % SURF(AX,...) plots into AX instead of GCA.
|
| | 29 | %
|
| | 30 | % SURF returns a handle to a surface plot object.
|
| | 31 | %
|
| | 32 | % AXIS, CAXIS, COLORMAP, HOLD, SHADING and VIEW set figure, axes, and
|
| | 33 | % surface properties which affect the display of the surface.
|
| | 34 | %
|
| | 35 | % See also SURFC, SURFL, MESH, SHADING.
|
| | 36 |
|
| | 37 | %-------------------------------
|
| | 38 | % Additional details:
|
| | 39 | %
|
| | 40 | % If the NextPlot axis property is REPLACE (HOLD is off), SURF resets
|
| | 41 | % all axis properties, except Position, to their default values
|
| | 42 | % and deletes all axis children (line, patch, surf, image, and
|
| | 43 | % text objects).
|
| | 44 |
|
| | 45 | % Copyright 1984-2017 The MathWorks, Inc.
|
| | 46 |
|
| | 47 | % J.N. Little 1-5-92
|
| | 48 |
|
< 0.001 | 2 | 49 | narginchk(1,inf)
|
| | 50 |
|
0.026 | 2 | 51 | [~, cax, args] = parseplotapi(varargin{:},'-mfilename',mfilename);
|
< 0.001 | 2 | 52 | nargs = length(args);
|
0.001 | 2 | 53 | args = matlab.graphics.internal.convertStringToCharArgs(args);
|
< 0.001 | 2 | 54 | hadParentAsPVPair = false;
|
< 0.001 | 2 | 55 | if nargs > 1
|
| | 56 | % try to fetch axes handle from input args,
|
| | 57 | % and allow it to override the possible input "cax"
|
< 0.001 | 2 | 58 | for i = 1:length(args)
|
0.003 | 6 | 59 | isValid = ~isempty(args{i}) && matlab.graphics.internal.isCharOrString(args{i});
|
0.002 | 6 | 60 | hasParentArg = strncmpi(args{i}, 'parent', length(args{i}));
|
< 0.001 | 6 | 61 | if isValid && hasParentArg && nargs > i
|
| | 62 | cax = args{i+1};
|
| | 63 | hadParentAsPVPair = true;
|
| | 64 | break;
|
< 0.001 | 6 | 65 | end
|
0.002 | 6 | 66 | end
|
< 0.001 | 2 | 67 | end
|
| | 68 |
|
| | 69 | % do input checking
|
0.007 | 2 | 70 | dataargs = parseparams(args);
|
0.006 | 2 | 71 | error(surfchk(dataargs{:}));
|
| | 72 |
|
| | 73 | % use nextplot unless user specified an axes handle in pv pairs
|
| | 74 | % required for backwards compatibility
|
< 0.001 | 2 | 75 | if isempty(cax) || ~hadParentAsPVPair
|
< 0.001 | 2 | 76 | if ~isempty(cax) && ~ishghandle(cax,'Axes')
|
| | 77 | parax = cax;
|
| | 78 | cax = ancestor(cax,'Axes');
|
| | 79 | nextPlot = 'add';
|
< 0.001 | 2 | 80 | else
|
0.001 | 2 | 81 | showInteractionInfoPanel = isempty(get(groot,'CurrentFigure'));
|
0.003 | 2 | 82 | res = matlab.ui.internal.webGraphicsStateManager;
|
0.021 | 2 | 83 | cax = newplot(cax);
|
< 0.001 | 2 | 84 | parax = cax;
|
< 0.001 | 2 | 85 | nextPlot = cax.NextPlot;
|
< 0.001 | 2 | 86 | if showInteractionInfoPanel
|
| | 87 | % Maybe open the Interaction Info Panel
|
| | 88 | matlab.graphics.internal.InteractionInfoPanel.maybeShow(cax);
|
< 0.001 | 2 | 89 | end
|
< 0.001 | 2 | 90 | end
|
| | 91 | else
|
| | 92 | cax = newplot(cax);
|
| | 93 | parax = cax;
|
| | 94 | nextPlot = cax.NextPlot;
|
< 0.001 | 2 | 95 | end
|
| | 96 | % We need to separate out convenience arguments from P/V pairs:
|
| | 97 | % First, determine the number of numeric data arguments:
|
< 0.001 | 2 | 98 | len = length(args);
|
< 0.001 | 2 | 99 | n = 1;
|
0.001 | 2 | 100 | while n<=len && isplottable(args{n})
|
< 0.001 | 6 | 101 | n = n+1;
|
< 0.001 | 6 | 102 | end
|
< 0.001 | 2 | 103 | n = n-1;
|
| | 104 | % Determine the appropriate syntax:
|
< 0.001 | 2 | 105 | params = {};
|
< 0.001 | 2 | 106 | switch(n)
|
< 0.001 | 2 | 107 | case 1
|
| | 108 | % SURF(Z,...)
|
| | 109 | z = args{1};
|
| | 110 | matlab.graphics.internal.configureAxes(cax,[],[],z);
|
| | 111 | [~,~,z] = matlab.graphics.internal.makeNumeric(cax,[],[],z);
|
| | 112 | params = {'ZData',z};
|
| | 113 | args = args(2:end);
|
< 0.001 | 2 | 114 | case 2
|
| | 115 | % SURF(Z,C,...)
|
| | 116 | z = args{1};
|
| | 117 | matlab.graphics.internal.configureAxes(cax,[],[],z);
|
| | 118 | [~,~,z] = matlab.graphics.internal.makeNumeric(cax,[],[],z);
|
| | 119 | params = {'ZData',z,'CData',args{2}};
|
| | 120 | args = args(3:end);
|
< 0.001 | 2 | 121 | case 3
|
| | 122 | % SURF(X,Y,Z,...)
|
< 0.001 | 2 | 123 | x = args{1};
|
< 0.001 | 2 | 124 | y = args{2};
|
< 0.001 | 2 | 125 | z = args{3};
|
0.021 | 2 | 126 | matlab.graphics.internal.configureAxes(cax,x,y,z);
|
0.011 | 2 | 127 | [x,y,z] = matlab.graphics.internal.makeNumeric(cax,x,y,z);
|
< 0.001 | 2 | 128 | params = {'XData',x,'YData',y,'ZData',z};
|
< 0.001 | 2 | 129 | args = args(4:end);
|
| | 130 | case 4
|
| | 131 | % SURF(X,Y,Z,C,...)
|
| | 132 | x = args{1};
|
| | 133 | y = args{2};
|
| | 134 | z = args{3};
|
| | 135 | matlab.graphics.internal.configureAxes(cax,x,y,z);
|
| | 136 | [x,y,z] = matlab.graphics.internal.makeNumeric(cax,x,y,z);
|
| | 137 | params = {'XData',x,'YData',y,'ZData',z,'CData',args{4}};
|
| | 138 | args = args(5:end);
|
< 0.001 | 2 | 139 | end
|
| | 140 |
|
| | 141 | %Place parenting arguments first so that parent-sensitive properties
|
| | 142 | %eg. UIContextMenu are set after surface is parented.
|
< 0.001 | 2 | 143 | allargs = [params, {'Parent',parax}, args];
|
| | 144 |
|
0.019 | 2 | 145 | hh = matlab.graphics.chart.primitive.Surface(allargs{:});
|
| | 146 |
|
< 0.001 | 2 | 147 | switch nextPlot
|
< 0.001 | 2 | 148 | case {'replaceall','replace'}
|
0.010 | 2 | 149 | view(cax,3);
|
0.011 | 2 | 150 | grid(cax,'on');
|
| | 151 | case {'replacechildren'}
|
| | 152 | view(cax,3);
|
< 0.001 | 2 | 153 | end
|
| | 154 |
|
< 0.001 | 2 | 155 | if nargout == 1
|
| | 156 | h = hh;
|
< 0.001 | 2 | 157 | end
|
Other subfunctions in this file are not included in this listing.