多语言展示
当前在线:1488今日阅读:60今日分享:41

MatLab中画雪人

MatLab中画雪人
工具/原料

matlab2019b

方法/步骤
1

思路1. 画出左右手:可以用线段表示2. 画头、身体:用圆表示3. 画眼睛:用小圆表示4. 画嘴巴:用小小的二次曲线表示5. 画鼻子:用尖尖的三角形表示6. 画帽子:用四边形表示7. 添加其他想要的文字

2

具体代码clc;close all; figure; patch([-12 -12 7 7],[-12 3 3 -12],[  0.5843    0.8157    0.9882]); axis equal; axis([-12 7 -12 3]); hold on; t=0:0.01:2*pi; %left hand plot([-1.8 -4],[-2.9 -1],'r','linewidth',4); %right hand plot([1.8 4],[-2.9 -1],'r','linewidth',4); %upper circle x=cos(t);y=sin(t); fill(x,y,'w'); %middle circle x=2*cos(t);y=-2.8+2*sin(t); fill(x,y,'w'); %lower circle x=3*cos(t);y=-7.5+3*sin(t); fill(x,y,'w'); %botam x=0.25*cos(t);y=-2+0.25*sin(t); fill(x,y,'k'); x=0.25*cos(t);y=-4+0.25*sin(t); fill(x,y,'k'); x=0.25*cos(t);y=-7+0.25*sin(t); fill(x,y,'k'); x=0.25*cos(t);y=-9+0.25*sin(t); fill(x,y,'k'); %eyes x=-0.5+0.25*cos(t);y=0.4+0.25*sin(t); fill(x,y,'k'); x=0.5+0.2*cos(t);y=0.4+0.2*sin(t); fill(x,y,'k'); %mouth t=-0.3:0.1:0.3; y=t.^2-0.5; plot(t,y,'k','linewidth',2); %hat plot([-1 1],[0.8 0.8],'k','linewidth',5); fill([-0.6 -0.6 0.6 0.6],[0.8 2 2 0.8],'k'); %nose patch([-0.15 -0.15 1.5],[0.1 -0.2 -0.3],[1 0.5 0]); text(-10,2,'HAPPY CHRISTMAS','Color','black','FontSize',30)

3

结果展示

推荐信息