【发布时间】:2018-05-04 12:17:40
【问题描述】:
我想通过函数trisurf 绘制一个三角形曲面图,以指定轴为目标。但是,MATLAB 文档没有说明任何语法来做到这一点。当我打开函数时,我得到以下第一行:
function hh = trisurf(tri,varargin)
%TRISURF Triangular surface plot
% TRISURF(TRI,X,Y,Z,C) displays the triangles defined in the M-by-3
% face matrix TRI as a surface. A row of TRI contains indexes into
% the X,Y, and Z vertex vectors to define a single triangular face.
% The color is defined by the vector C.
%
% TRISURF(TRI,X,Y,Z) uses C = Z, so color is proportional to surface
% height.
%
% TRISURF(TR) displays the triangles in the triangulation TR. It uses
% C = TR.X(:,3) to color the surface proportional to height.
%
% H = TRISURF(...) returns a patch handle.
%
% TRISURF(...,'param','value','param','value'...) allows additional
% patch param/value pairs to be used when creating the patch object.
%
% Example:
%
% [x,y] = meshgrid(1:15,1:15);
% tri = delaunay(x,y);
% z = peaks(15);
% trisurf(tri,x,y,z)
%
% % Alternatively
% tr = triangulation(tri, x(:), y(:), z(:));
% trisurf(tr)
%
% See also PATCH, TRIMESH, DELAUNAY, triangulation, delaunayTriangulation.
% Copyright 1984-2017 The MathWorks, Inc.
narginchk(1,inf);
ax = axescheck(varargin{:});
ax = newplot(ax);
start = 1;
函数输入不定义为varargin,例如在函数surf 中定义,因此无法将轴句柄指定为第一个输入变量。如果将轴句柄指定为第二个输入变量,则函数axescheck 会识别该句柄,但后来我得到一个错误,因为预期的第二个输入变量是一个向量。如果将轴句柄指定为第三个输入变量,则函数axescheck 根本无法识别该句柄。
我知道我可以先激活轴,然后调用trisurf,但我将它放在一个循环中,因此不建议这样做。有没有其他解决办法?
【问题讨论】:
标签: matlab axis handle surface triangular