I need to generate a discontinuous plot (piecewise in each triangle) in matlab, something like:
This plot is from http://www.alecjacobson.com/weblog/?p=3616, but I don't understand how generate it.
I have two matrices corresponding to a triangular mesh of a domain (typical of finite elements method, that is, no overlaped triangles, the union of all triangles is equal to the domain...):
coord=[x1,y1;x2,y2;...;xnod,ynod] % vertices of the mesh ele =[n1,n2,n3;n1,n2,n3;...;n1,n2,n3] % mesh conectivity
coord(1,:)=[x1,y1] are the coordinates of vertex 1 of the mesh (vertex of some triangle) coord(2,:)=[x2,y2] are the coordinates of vertex 2 of the mesh (vertex of some triangle) etc, ele(1,:)=[n1,n2,n3] is the number of the vertices of triangle 1 ele(2,:)=[n1,n2,n3] is the number of the vertices of triangle 2 etc.
This way, for example,
are the coordinates (x1,y1), (x2,y2) and (x3,y3) of the vertices of triangle 4.
The solution that I need to plot is a vector "u" which size is the number of triangles of the mesh (=number of rows of "elem"), because this solution is one constant over each triangle.
How can I plot this discontinuous solution?