MATLAB: Use of C vector in trimesh function

MATLABtrimesh color colour

I'm having some difficulty understanding the use of the colour vector in the trimesh function. The function is used as follows:
trimesh(Tri,X,Y,Z,C)
Where Tri is a vector of index references to X, Y and Z where each row defines a triangle and X, Y and Z are the Cartesian coordinates of the vertices within the mesh.
If you leave the C vector out, my mesh is rendered without any problems. But I need to highlight specific parts of the mesh and so want to use the C vector to change the colour of some areas.
What I don't understand is the final input, C, which defines the edge colours. What format should it be in and what element of the mesh does each row of C refer to? I've tried using the standard MATLAB colour specification outlined here, but I get error messages telling me that it's not the correct format.
I'd appreciate it if anyone could explain this to me. Many thanks for your time!

Best Answer

I think I may have solved it. Just for reference in case anyone else ever struggles with this I'll explain how I think it works below. Please correct me if I am mistaken.
The values of C are numeric and are automatically scaled over the full colour range.
Each element in the C vector corresponds to a vertex in the mesh. The edges are then coloured, based on the order of the Tri nx3 array.
For example, if Tri was:
[ 1 2 3,
3 2 4,
3 5 6 ]
And C was:
[ 5,
10,
30,
60,
70,
150 ]
The first edge listed in Tri is 1 to 2. The edge is coloured using the colour of point 1, which is 5. Then edge 2 to 3 is drawn using the colour value for point 2, which is 10. This continues until the final edge, 6 to 3 using colour value 150.
As I said, this is just guessed from the behaviour I have observed in MATLAB, if anyone can correct me please do so.
Related Question