|
⇤ ← Revision 1 as of 2025-12-17 19:33:49
Size: 925
Comment: Initial commit
|
Size: 1016
Comment: Fix markup
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 25: | Line 25: |
| }}] | xlim([-3 3]); ylim([-3 3]); title("Title"); xlabel('x'); ylabel('y'); zlabel('z'); }}} |
MATLAB trisurf
The trisurf function creates a 3D graph.
Contents
Usage
The trisurf function creates a 3D graph based on a triangulation. Such a matrix can be created by convhull, like:
% Create a rectangular grid.
[X,Y,Z] = meshgrid(linspace(-3,3,20), linspace(-3,3,20), linspace(-3,3,20));
% Identify the points within a region of integration.
roi = (X>=0 & X<=sqrt(4-Z.^2-Y.^2)) & (Y>=0 & Y<=sqrt(4-Z.^2) & (Z>=0 & Z<=1));
% Calculate the convex hull of this ROI and plot.
K = convhull(X(roi), Y(roi), Z(roi));
trisurf(K, X(roi), Y(roi), Z(roi));
xlim([-3 3]);
ylim([-3 3]);
title("Title");
xlabel('x');
ylabel('y');
zlabel('z');Alternatively, see this example using delaunay:
% Create a grid. [X,Y] = meshgrid(1:15,1:15); % Evaluate the peaks function on a 15x15 grid. Z = peaks(15); % Triangulate and plot. T = delaunay(X,Y); trisurf(T, X,Y,Z);
