trimesh (2024)

Table of Contents
Syntax Inputs Outputs Examples Comments

Creates a 3D triangulated mesh.

Syntax

h = trimesh(tri, x, y, z)

h = trimesh(tri, x, y, cdata)

h = trimesh(tri, x, y)

h = trimesh(..., property, value, ...)

h = trimesh(hAxes, ...)

Inputs

tri
An Mx3 matrix, where M is the number of triangles. Each row contains the indices of a triangle in the x, y and z matrices. Usually, tri is the output of the delaunay function.
Type: integer
Dimension: vector | matrix
x, y, z
Coordinates of the vertices.
Type: double | integer
Dimension: vector | matrix
cdata
Color data for each vertex or triangle. cdata can be:
  1. a vector that contains a scalar value for each vertex
  2. a vector that contains a scalar value for each triangle
  3. an Mx3 matrix that contains an rgb color for each triangle
Type: double | integer
Dimension: vector | matrix
property
Properties that control the appearance or behavior of the graphics object.
Type: string
Dimension: scalar
value
Value of the properties.
Type: double | integer | string
Dimension: scalar | vector
hAxes
Axis handle.
Type: double
Dimension: scalar

Outputs

h
Handle of the trimesh graphics object.

Examples

Simple trimesh example:

[x, y] = meshgrid([0:0.2:2]);z = sin(x)'*cos(y);tri = delaunay (x(:), y(:));figure;h = trimesh(tri, x, y, z);

trimesh (1)

Set trimesh edgecolor:

[x, y] = meshgrid([0:0.4:2*pi]);z=sin(x')*cos(x);tri = delaunay (x(:), y(:));figure;h = trimesh(tri, x, y, z);set(h,'edgecolor','r')

trimesh (2)

Set cdata per vertex:

[x, y] = meshgrid([0:0.2:2]);z = sin(x)'*cos(y);tri = delaunay (x(:), y(:));figure;% cdata is a scalar per vertexcdata = x(:);h = trimesh(tri, x, y, z, cdata);figure;h = trimesh(tri, x, y, z, cdata);% the edge color is interpolatedset(h, 'edgecolor','interp');

trimesh (3)

trimesh (4)

Set cdata per triangle:

[x, y] = meshgrid([0:0.5:2]);z = cos(y)'*sin(x);tri = delaunay (x(:), y(:));figure;% cdata is a scalar per trianglecdata = 1:size(tri)(1);h = trimesh(tri, x, y, z, cdata);colormap(jet(12))colorbar;figure;% cdata is an rgb color per trianglecdata = plasma(size(tri)(1));h = trimesh(tri, x, y, z, cdata);

trimesh (5)

trimesh (6)

Comments

If there are no axes, they will be created first.

If z is omitted, a triplot will be created instead.

trimesh (2024)
Top Articles
Latest Posts
Article information

Author: Wyatt Volkman LLD

Last Updated:

Views: 6154

Rating: 4.6 / 5 (46 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Wyatt Volkman LLD

Birthday: 1992-02-16

Address: Suite 851 78549 Lubowitz Well, Wardside, TX 98080-8615

Phone: +67618977178100

Job: Manufacturing Director

Hobby: Running, Mountaineering, Inline skating, Writing, Baton twirling, Computer programming, Stone skipping

Introduction: My name is Wyatt Volkman LLD, I am a handsome, rich, comfortable, lively, zealous, graceful, gifted person who loves writing and wants to share my knowledge and understanding with you.