实验课题四曲面图与统计图
第一大题:编程作下列曲面绘图:
用平面曲线r=2+cos(t)+sin(t),t∈(0,π)绘制旋转曲面
t=0:0.02*pi:pi;
r=2+cos(t)+sin(t);
cylinder(r,30)
title('旋转曲面');
shading interp
用直角坐标绘制双曲抛物面曲面网线图,z2=xy (-3<x<3,-3<y<3) [x,y]=meshgrid(-3:0.1:3);
z2=x.*y;
surf(x,y,z2);
title('双曲抛物面');
shading interp
axis off
用直角坐标绘制曲面表面图,y
=(-5<x<5,-5<y<5)
32-
z2
x
[x,y]=meshgrid(-5:0.1:5);
z3=(x.^2)-2*y;
surf(x,y,z3);
title('picture 3');
shading interp
axis off
用直角坐标绘制修饰过的光滑曲面曲面:z 4=sin(x )-cos(y ) x 与y 的取值在(-π,π)
[x,y]=meshgrid(-pi:0.02*pi:pi); z4=sin(x)-cos(y); surf(x,y,z4); title('picture 4'); shading interp axis off
用连续函数绘图方法绘制曲面)2sin(6522x y x z ++=,x ∈[-2pi,2pi], y ∈[-2pi,2pi],并作图形修饰。
ezsurf(@(x,y)(x^2+y^2+6*sin(2*x)),[-2*pi 2*pi -2*pi 2*pi]) title('picture 5'); shading interp axis off
第二大题:按要求作下列问题的统计图:
x21是1—10的10维自然数构成的向量,y21是随机产生的10维整数向量,画出条形图。
(提示bar(x,y)) x21=1:10; y21=randn(10,1); bar(x21,y21)
随机生成50维向量y22,画出分5组的数据直方图。
(提示hist(y,n))
y22=randn(50,1);
hist(y22,5)
由以下数据绘出饼形图y23=(46 75 148 214 98 35),并抽出第四块。
(提示pie(y))
y23=[46 75 148 214 98 35];
pie(y23,[0 0 0 1 0 0])
调用函数数据绘其平面等高线,绘图数据用[x,y,z]=peaks(30)生成。
(提示contour(x,y,z,15) )
[x,y,z]=peaks(30);
contour(x,y,z,15)
第三大题应用问题:作数据饼形图及条形图
初中毕业生状况统计:
某年代欧洲若干国家初中毕业生升学、就业统计数据如下,作出饼形图及条形图,以便分析不同国家对青年培训的做法上的差异。
数据资料如下:
(提示:将九行四列的数据构成矩阵A,对A的每一行作饼形图pie( ) ,对矩阵A作条形图bar() )
A=[56 36 4 4;21 19 51 9;31 31 23 15;27 40 14 19;21 51 24 4;26 29 9 26;56 10 5 29;24 13 31 32;32 10 14 44]; A=A./100;
subplot(2,5,1)
pie(A(1,:))
title('比利时')
subplot(2,5,2)
pie(A(2,:))
title('德国')
subplot(2,5,3)
pie(A(3,:))
title('卢森堡')
subplot(2,5,4)
pie(A(4,:))
title('法国')
subplot(2,5,5)
pie(A(5,:))
title('意大利') subplot(2,5,6) pie(A(6,:)) title('荷兰') subplot(2,5,7) pie(A(7,:)) title('爱尔兰') subplot(2,5,8) pie(A(8,:)) title('丹麦') subplot(2,5,9) pie(A(9,:)) title('英国') subplot(2,5,10) bar(A)
第四大题绘制动态图
4.1 应用函数comet(x,y)作二维动态曲线图(西瓜图):
ππ5.55.5cos *sin :⎩
⎨⎧≤≤-==t t t y t x l t=-5.5*pi:pi/50:5.5*pi; comet(sin(t),t.*cos(t)) 4.2 应用函数
comet3(x,y,z)作三维动态曲线图:
1000)3cos(5)sin(22:2≤≤⎪⎩
⎪
⎨⎧===t t z t y t x l (提示:t=0:0.01:100运行时将图形窗口放在可视的旁
边)
t=0:0.01:100;
comet3(2*t.^2,2*sin(t),5*cos(3*t))。