四结点的平面单元
function plot_plane_4_nodes(p,t,U) %%% 传入的t需要是Nelem*m的,Nelem的是单元总数,m是一个单元含有的结点数目 %%% 传入的p是Nnode*3的,Nnode的是结点总数,3列坐标分别为Xcoord,Ycoord,Zcoord %%% 传入的U是列向量,数目和p的行数相同 figure;axis equal %===== map ===== map = [0 0 255; 0 160 255; 0 255 255; 0 255 160; 0 255 0; 178 255 0; 255 255 0; 255 145 0; 255 0 0;]./255; colormap(map) %%% 'Faces'后面的参数指定哪些结点构成一个面(每一行是一个面的顶点编号),即单元信息 %%% 'Vertices'后面的参数是一系列顶点坐标(每一行是一个顶点坐标),即结点信息 %%% 'FaceVertexCData'后面的参数是一系列顶点坐标的值,会自动插值颜色,值即结点位移 ss=patch('Faces',t(:,[1,2,3,4]),'Vertices',p,'FaceVertexCData',U); ss.FaceColor = 'interp'; ss.EdgeColor='black'; %%% none , white ss.LineStyle = '-'; ss.LineWidth = 0.01; colorbar
六面体或四面体绘制6个面或者4个面即可
edge_color = 'black';
patch('Faces',t(:,[1,2,3,4]),'Vertices',p1,'FaceColor','interp','EdgeColor',edge_color,'FaceVertexCData',U);
patch('Faces',t(:,[5,6,7,8]),'Vertices',p1,'FaceColor','interp','EdgeColor',edge_color,'FaceVertexCData',U);
patch('Faces',t(:,[1,5,8,4]),'Vertices',p1,'FaceColor','interp','EdgeColor',edge_color,'FaceVertexCData',U);
patch('Faces',t(:,[2,6,7,3]),'Vertices',p1,'FaceColor','interp','EdgeColor',edge_color,'FaceVertexCData',U);
patch('Faces',t(:,[1,2,6,5]),'Vertices',p1,'FaceColor','interp','EdgeColor',edge_color,'FaceVertexCData',U);
ss=patch('Faces',t(:,[4,3,7,8]),'Vertices',p1,'FaceColor','flat','EdgeColor',edge_color,'FaceVertexCData',U);
ss.FaceColor = 'interp';