题目:
例如,在matlab里画出下图,并填充其中,1 2 3 4 5 6 7 是点的编号坐标分别为 1(1,1), 2(1,2),
3(2,2), 4(3,2), 5(3,1), 6(2,1), 7(2.5,1.5)各三角形顶点分别为(1): 1 6 2 (2):
6 3 2(3): 6 7 3(4): 6 5 7(5): 5 4 7(6): 4 3 6
%x表示三角形的三个顶点的横坐标
%y表示对应于y的三个顶点的纵坐标
x1=[1 2 1];y1=[1 1 2];
x2=[1 2 2];y2=[2 1 2];
x3=[2 2 2.5];y3=[1 2 1.5];
x4=[2 2.5 3];y4=[1 1.5 1];
x5=[2.5 3 3];y5=[1.5 1 2];
x6=[2 2.5 3];y6=[2 1.5 2];
fill(x1,y1,'y');hold on
fill(x2,y2,'m');hold on
fill(x3,y3,'c');hold on
fill(x4,y4,'r');hold on
fill(x5,y5,'b') ;hold on
fill(x6,y6,'g')
结果如下:
gplot(ones(3),rand(3))
或fill(rand(3,1),rand(3,1),'w')
或patch(rand(3,1),rand(3,1),'w')