You can build such a colormap yourself. Take this example:

r = [1 0 0];       %# start
w = [.9 .9 .9];    %# middle
b = [0 0 1];       %# end

%# colormap of size 64-by-3, ranging from red -> white -> blue
c1 = zeros(32,3); c2 = zeros(32,3);
for i=1:3
    c1(:,i) = linspace(r(i), w(i), 32);
    c2(:,i) = linspace(w(i), b(i), 32);
end
c = [c1(1:end-1,:);c2];

surf(peaks), shading interp
caxis([-8 8]), colormap(c), colorbar

Answer from Amro on Stack Overflow
🌐
MathWorks
mathworks.com › matlab › mathematics › computational geometry › delaunay triangulation
trisurf - Triangular surface plot - MATLAB
[x,y] = meshgrid(1:15,1:15); z = peaks(15); T = delaunay(x,y); trisurf(T,x,y,z) Alternatively, you can create and plot a triangulation object. ... Triangle connectivity, specified as a 3-column matrix where each row contains the point vertices defining a triangle face. ... Face color, specified as a matrix of colormap indices the same size as z.
🌐
MathWorks
mathworks.com › matlabcentral › answers › 1581389-colormapdata-for-trisurf
colormapdata for trisurf? - MATLAB Answers - MATLAB Central
November 8, 2021 - Colormapdata has only 1 value per node (Nx3 array). For example, for each point on the surface, I have 1 temperature value. Sign in to comment. Sign in to answer this question. ... F= faces and P=points from triangulation. Field is NX1 array. P is Nx3 array. ... Sign in to comment. Sign in to answer this question. MATLAB Mathematics Computational Geometry Triangulation Representation
Top answer
1 of 1
1

Why the trisurf(x,y,z,c) approach isn't working

You can't use the trisurf(x,y,z,c) approach because c has to be the same length as your Triangulation matrix, which it won't be. This is because you won't generate the same number of triangular faces from your matrix as you have points in your matrix.

It's worth mention that it's not recommended (says so in the documentation) that you use MATLAB DelaunayTri() function. Instead, you should use MATLAB's delaunayTriangulation() function.

##A Working Approach to Coloring Triangular Surfaces##

Below, I have detailed / commented a block of code that will color the triangular surfaces drawn from your interiorPoints variable according to the color values stored in the 4th column of your matrix variable.

In this code, I have mapped the color values to varying shades of blue and I have mapped the color values to MATLAB's jet color map. If you would like, you could create 5th and 6th columns in your matrix variable so that you can specify the R, G, and B color components for more vibrant color mappings:

interiorPoints = [matrix(:,1),matrix(:,2),matrix(:,3)];
c=matrix(:,4);

% MATLAB recommends that you use delaunayTriangle...
% DT = DelaunayTri(interiorPoints); 

DT = delaunayTriangulation(x,y,z)
hullFacets = convexHull(DT)

% Create an empty RGB colormap
custom_cm = zeros(length(c),3);
% Or, instead of creating an empty color map, you could modify one of MATLAB's available color maps
modify_cm = colormap(jet) % Replace 'jet' with any other of MATLAB's available color maps 

% "B" is the 3rd component of this RGB color map
custom_cm(:,3) = ((c-min(c))/(max(c)-min(c))*length(c)) / length(c)

% Expand the scaled custom_cm column for multiplication with the original color matrix
cm_multiplier = repmat(custom_cm(:,3), 1, 3);
% Multiply element-wise the expanded custom_cm with the original color matrix
modify_cm = cm_multiplier.*modify_cm;

trisurf(hullFacets, DT.Points(:,1), DT.Points(:,2), DT.Points(:,3))

% Use the entirely custom color mapping
colormap(custom_cm)

% Or, use the modified color mapping
colormap(modify_cm)

I don't have the data stored in your matrix variable, so I triangulated some sample data and colored it according to a random set of data I generated as a 4th column. Here's how it came out looking using the entirely custom color map:

Here's how it came out looking using the modified jet color map:

🌐
Johns Hopkins University
math.jhu.edu › ~shiffman › 370 › help › techdoc › ref › trisurf.html
trisurf (MATLAB Function Reference)
Each row of Tri defines a single triangular face by indexing into the vectors or matrices that contain the X, Y, and Z vertices. trisurf(Tri,X,Y,Z,C) specifies color defined by C in the same manner as the surf function. MATLAB performs a linear transformation on this data to obtain colors from ...
🌐
MathWorks
mathworks.com › matlabcentral › answers › 153549-limit-number-of-colormap-points-in-a-trisurf
Limit number of colormap points in a trisurf - MATLAB Answers - MATLAB Central
September 5, 2014 - unfortunatly I am only able to limit the number of colors used in the colorbar, but not the trisurf itself.I know that i can change the shading to flat, but I need a slight interpolation of the color inbetween the points, but the colors used inbetween should still be limited by colormap; ... https://www.mathworks.com/matlabcentral/answers/153549-limit-number-of-colormap-points-in-a-trisurf#comment_235560
🌐
MathWorks
mathworks.com › matlab › graphics › labels and styling › color and styling
colormap - View and set current colormap - MATLAB
colorbar | colormaplist | ind2rgb | hsv2rgb | rgbplot ... Run the command by entering it in the MATLAB Command Window.
Find elsewhere
🌐
MathWorks
mathworks.com › matlab › graphics › 2-d and 3-d plots › surfaces, volumes, and polygons › surface and mesh plots
surf - Surface plot - MATLAB
Color array, specified as an m-by-n matrix of colormap indices or as an m-by-n-by-3 array of RGB triplets, where Z is m-by-n.
🌐
MathWorks
mathworks.com › matlab › graphics › labels and styling › color and styling
How Surface Plot Data Relates to a Colormap - MATLAB & Simulink
When you create surface plots using functions such as surf or mesh, you can customize the color scheme by calling the colormap function. If you want further control over the appearance, you can change the direction or pattern of the colors across the surface.
🌐
MathWorks
mathworks.com › matlabcentral › answers › 72308-multiple-trisurf-plots-with-different-colours
Multiple trisurf plots with different colours - MATLAB Answers - MATLAB Central
April 17, 2013 - The 4th parameter in trisurf, C, tells matlab how to find the colors for your surface(points). In your case C is Z1 for the first and Z2 for the second surface plot. So, the smaller a value in Z1 (or Z2) is, the more bluish it gets and the larger ...
🌐
Upc
www-eio.upc.edu › lceio › manuals › matlab › TECHDOC › REF › TRISURF.HTML
trisurf
trisurf(Tri,X,Y,Z,C) specifies color defined by C in the same manner as the surf function. MATLAB performs a linear transformation on this data to obtain colors from the current colormap.
🌐
MathWorks
mathworks.com › matlab › graphics › 2-d and 3-d plots › surfaces, volumes, and polygons › surface and mesh plots
surfl - Surface plot with colormap-based lighting - MATLAB
Then plot them as a surface using colormap-based lighting. The surface uses Z for height and both Z and the light source for color. [X,Y] = meshgrid(1:0.5:10,1:20); Z = sin(X) + cos(Y); surfl(X,Y,Z) ... Create three matrices of the same size. Then plot them as a surface with highlights from ...
🌐
MathWorks
mathworks.com › matlabcentral › answers › 40064-plotting-contour-on-surface-created-with-trisurf
Plotting contour on surface created with trisurf - MATLAB Answers - MATLAB Central
June 1, 2012 - I have scattered data in form of (x,y,z) that are points on a sphere. I have plotted the sphere using trisurf command and have used colormap on the basis of a vector Pindex. code: tri=delaunay(x...
🌐
MathWorks
mathworks.com › matlab › graphics › labels and styling › color and styling
Change Color Scheme Using a Colormap - MATLAB & Simulink
MATLAB® uses a default color scheme when it displays visualizations such as surface plots. You can change the color scheme by specifying a colormap.
🌐
MathWorks
mathworks.com › matlabcentral › answers › 569067-change-color-or-surface-and-points-above-an-upper-limit-using-scatter3-and-trisurf
Change color or surface and points above an upper limit using scatter3 and trisurf. - MATLAB Answers - MATLAB Central
July 22, 2020 - Hi all! I am having trouble with colormapping. I would like to make all points and surface below a user set upper limit to have the colormap jet, but points and surface above this limit be red. Her...