I would like to make a triangular surface plot throught the function trisurf
, targeting a specified axis. However, MATLAB documentation does not indicate any syntax to do that. When I open the function I get the following first lines:
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;
The function input is not defined just as varargin
, as it is done in function surf
for example, so it is not possible to specify the axis handle as first input variable. If the axis handle is specified as second input variable, the function axescheck
recognize the handle, but later I get an error because the expected second input variable is a vector. If the axis handle is specified as third input variable the function axescheck
does not recognize the handle at all.
I know that I can first activate the axis and then call trisurf
, but I have this inside a loop so it is not advisable to do that. Is there any other solution?