gusucode.com > 《精通matlab 7》包括配套光盘 > 配套光盘里的程序附件/Ex-24/Ex2416.m
%例24-16 设置多个片块模型的颜色 %Ex24-16 set colors in multi-patches model clear close all Vm=[0 0 0;1 0 0;1 0 1;0 0 1;0 1 1;1 1 1;1 1 0]; Fm=[1 2 3 4;3 4 5 6;6 3 2 7]; subplot(3,2,1) patch('Vertices',Vm,'Faces',Fm,'FaceVertexCData',rand(1,1),'FaceColor','flat') view([30,30]);title('set uniform index-color') subplot(3,2,2) patch('Vertices',Vm,'Faces',Fm,'FaceVertexCData',rand(1,3),'FaceColor','flat') view([30,30]);title('set uniform RGB-color') subplot(3,2,3) patch('Vertices',Vm,'Faces',Fm,'FaceVertexCData',rand(size(Vm,1),1),'FaceColor','interp') view([30,30]);title('assign multi-index-color to Vertices') subplot(3,2,4) patch('Vertices',Vm,'Faces',Fm,'FaceVertexCData',rand(size(Vm,1),3),'FaceColor','interp') view([30,30]);title('assign multi-RGB-color to Vertices') subplot(3,2,5) patch('Vertices',Vm,'Faces',Fm,'FaceVertexCData',rand(size(Fm,1),1),'FaceColor','flat') view([30,30]);title('assign multi-index-color to Faces') subplot(3,2,6) patch('Vertices',Vm,'Faces',Fm,'FaceVertexCData',rand(size(Fm,1),3),'FaceColor','flat') view([30,30]);title('assign multi-RGB-color to Faces')