MATLAB程序设计与应用(第三版)刘卫国 答案(十)

第十章 MATLAB图形对象句柄

一、选择题

1~5:ADCACC

二、填空题

1.set;get。
2.字符;RGB三元组
3.Tag;findobj;hf=findobj(0,‘Tag’,‘ppp’)。
4.图形窗口;坐标轴。
5.矩形方框;Curvature

三、应用题

1.
代码如下:

x1=-2*pi:pi/100:2*pi;
y1=5./(1+sin(x1));
x2=-5:0.1:5;
y2=x2.^2+x2+1;
t=-2:0.1:2;
x3=cos(t/pi);
y3=2*sin(t/2*pi);
theta=-2*pi:pi/100:2*pi;
r=sin(2*theta);
subplot(2,2,1)
h1=plot(x1,y1)
text(0,10000,'5/sin(1+x)')
set(h1,'Color','r','LineStyle',':','LineWidth',1)
title('第(1)问')
subplot(2,2,2)
h2=plot(x2,y2)
text(0,20,'x2^2+x2+1')
set(h2,'Color','b','LineStyle','-.','LineWidth',2)
title('第(2)问')
subplot(2,2,3)
h3=plot(x3,y3)
text(0.9,0,'(3)')
set(h3,'Color','y','LineStyle','--','LineWidth',3)
title('第(3)问')
subplot(2,2,4)
h4=plot(theta,r)
text(8,0.4,'r=sin(2\theta)')
set(h4,'Color','g','LineStyle','-','LineWidth',4)
title('第(4)问')

在这里插入图片描述
2.
代码如下:

t=0:0.1:30;
x1=2*(cos(t)+t.*sin(t));
y1=2*(sin(t)-t.*cos(t));
z1=1.5*t;
u=linspace(-2,2,100);
v=linspace(-3,3,100);
x2=u.^2/2;
y2=u;
z2=v;
x3=-5:0.01:5;
y3=-5:0.01:5;
z3=x3.*y3.*exp(-x3.^2-y3.^2);
x4=-5:0.01:5;
y4=-5:0.01:5;
z4=x4.^2+y4.^2-5.*sin(x4.*y4);
subplot(2,2,1)
h1=plot3(x1,y1,z1)
set(h1,'Color','r','LineStyle',':','LineWidth',1)
title('第(1)问')
subplot(2,2,2)
h2=plot3(x2,y2,z2)
set(h2,'Color','b','LineStyle','-.')
title('第(2)问')
subplot(2,2,3)
h3=plot3(x3,y3,z3)
set(h3,'Color','y','LineStyle','--')
title('第(3)问')
subplot(2,2,4)
h4=plot3(x4,y4,z4)
set(h4,'Color','g','LineStyle','-')
title('第(4)问')

在这里插入图片描述
3.
代码如下:

x=[0:3 3:-1:0];x1=[3:6 6:-1:3];x2=[6:9 9:-1:6];
y=[2 2 2 2 3 3 3 3];
patch(x,y,'r')
patch(x1,y,'g')
patch(x2,y,'b')

在这里插入图片描述
4.
代码如下:

X=[1,1,1,1] ; X0=[ 1,1,2, 2] ;
Y=[1,2,2,1] ; Y0=[ 1,2,2, 1];
Z=[1,1,2,2] ; Z0=[ 2,2,2, 2];
C=[0.5,1.0,1.0,0.5]; C0=[ 1.0,0.5,0.5,0.1667];
X1=[ 2,2,1,1]; Y1=[ 1,1,1,1]; Z1=[ 1,2,2,1]; 
X2=[1,1,2,2];Y2=[1,2,2,1];Z2=[1,1,1,1];
X3=[2,2,2,2];Y3=[2,2,1,1];Z3=[1,2,2,1];
X4=[2,2,1,1];Y4=[2,2,2,2];Z4=[1,2,2,1];
C1=[0.5,0.1667,1.0,0.5];
C2=[0.333,0.667,0.5,0.8];
C3=[0.1667,1.0,0.6667,0.333];
C4=[0.1,0.5,0.4,0.9];
fill3(X,Y,Z,C,X0,Y0,Z0,C0,X1,Y1,Z1,C1,X2,Y2,Z2,C2,X3,Y3,Z3,C3,X4,Y4,Z4,C4);
axis off

在这里插入图片描述

v=[0,0,0;10,0,0;10,20,0;0,20,0;0,20,30;0,0,30;10,0,30;10,20,30];
f=[2,3,8,7;1,4,5,6;6,7,2,1;5,8,3,4;6,7,8,5;1,2,3,4];
mc=[0,0,1;0,1,0;1,0,0;0,1,1;1,0,1;1,1,0];
subplot(1,2,1);
patch('faces',f,'vertices',v,'facevertexcdata',mc,'facecolor','flat');
view(30,30);
axis([0,10,0,20,0,30]);
subplot(1,2,2);
patch('faces',f,'vertices',v,'facevertexcdata',mc,'facecolor','flat');
view(-120,-30);
axis([0,10,0,20,0,30]);
grid

在这里插入图片描述
若想要讲解可下方留言,看到就会回复!!!

  • 5
    点赞
  • 67
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值