当前位置:文档之家› 实验六 高层绘图操作答案

实验六 高层绘图操作答案

实验六 高层绘图操作
实验目的:
1. 掌握绘制二维图形的常用函数
2. 掌握绘制三维图形的常用函数
3. 掌握绘制图形的辅助操作
实验内容:
1. 1. 设x x x y cos 2^1sin 35.0⎥⎦
⎤⎢⎣⎡++=,在π2~0=x 区间取101点,绘制函数曲线。

x=0:pi/100:2*pi;
y=(0.5+3*sin(x)./(1+x..^2)).*cos(x);
plot(x,y);
2. 已知21x y =,)2cos(2x y =,213y y y ⨯=,完成下列操作:
(1) 在同一坐标系下用不同的颜色和线型绘制三条曲线。

(2) 以子图形式绘制三条曲线。

(3) 分别用条形图、阶梯图、杆图和填充图绘制三条曲线。

(1).在同一坐标系下用不同的颜色和线型绘制三条曲线。

x=0:pi/1000:2*pi;
y1=x.^2;
y2=cos(2*x);
y3=y1.*y2;
plot(x,y1,'r',x,y2,'b-.',x,y3,'k--');
(2). 以子图形式绘制三条曲线。

x=0:pi/10:2*pi;
y1=x.^2;
subplot(2,2,1);plot(x,y1,'r');
title('y1=x^2');
y2=cos(2*x);
subplot(2,2,2);plot(x,y2,'b-.');
title('y2=cos(2*x)');
y3=y1.*y2;
subplot(2,2,3);plot(x,y3,'k--');
title('y3=y1.*y2');
(3). 分别用条形图、阶梯图、杆图和填充图绘制三条曲线。

x=0:pi/10:2*pi;
y1=x.^2;
subplot(2,2,1);bar(x,y1,'r');
title('y1=x^2');
subplot(2,2,2);stairs(x,y1,'r');
title('y1=x^2');
subplot(2,2,3);stem(x,y1,'r');
title('y1=x^2');
subplot(2,2,4);fill(x,y1,'r');
title('y1=x^2');
x=0:pi/10:2*pi;
y2=cos(2*x);
subplot(2,2,1);bar(x,y2,'b'); title(' y2=cos(2*x)'); subplot(2,2,2);stairs(x,y2,'b'); title(' y2=cos(2*x)'); subplot(2,2,3);stem(x,y2, 'b'); title(' y2=cos(2*x)'); subplot(2,2,4);fill(x,y2,'b'); title(' y2=cos(2*x)');
x=0:pi/10:2*pi;
y3=y1.*y2;
subplot(2,2,1);bar(x,y3,'m'); title(' y3=y1.*y2');
subplot(2,2,2);stairs(x,y3,'m'); title(' y3=y1.*y2');
subplot(2,2,3);stem(x,y3, 'm'); title(' y3=y1.*y2');
subplot(2,2,4);fill(x,y3, 'm');
title(' y3=y1.*y2');
3. 已知
⎪⎪⎩⎪⎪⎨⎧>++≤+=0),1ln(2
10,22x x x x e x y π 在55≤≤-x 绘制函数曲线。

x1=-5:0.01:0;
x2=0.01:0.01:5;
y1=(x1+sqrt(pi))./exp(2);
y2=log(x2+sqrt(1+x2.^2))./2;
plot(x1,y1,'b',x2,y2,'b');
4. 绘制极坐标曲线)sin(θρn b a +=,并分析参数a 、b 、n 对曲线形状的影响。

a=input('Input a:');
b=input('Input b:');
n=input('Input n:');
theta=0:0.01:2*pi;
rho=a*sin(b+n*theta);
polar(theta,rho);
5. 绘制函数的曲面图和等高线。

42
2cos cos y x ye x z +-=
其中x 的21个值均匀分布在[-5,5]范围,y 的31个值均匀分布在[0,10],要求使用subplot(2,1,1)和supplot(2,1,2)将产生的曲面图和等高线
图画在同一个窗口上。

x=linspace(-5,5,21);
y=linspace(0,10,31);
[X,Y]=meshgrid(x,y);
Z=cos(X).*cos(Y).*exp(-sqrt(X.^2+Y .^2)/4); subplot(2,1,1);surf(X,Y ,Z);
subplot(2,1,2);contour(X,Y ,Z,12);
6. 绘制曲面图形,并进行插值着色处理。

⎪⎩⎪⎨⎧=≤≤≤≤==s
z t s t s y t s x sin 230,20sin cos cos cos ππ
s=0:pi/50:pi/2;
t=0:pi/50:3/2*pi;
[s,t]=meshgrid(s,t);
x=cos(s).*cos(t);
y=cos(s).*sin(t);
z=sin(s);
surf(x,y,z);
shading interp;。

相关主题