当前位置:文档之家› matlab上机习题5 MATLAB7.0二维绘图

matlab上机习题5 MATLAB7.0二维绘图

matlab上机习题5 MATLAB7.0二维绘图
matlab上机习题5 MATLAB7.0二维绘图

实验五MATLAB7.0 二维绘图

实验目的:

①掌握绘制数据曲线图的方法;

②掌握绘制其他坐标系下的数据曲线图和统计分析图的方法;

③掌握绘制隐函数图形的方法。

④掌握图形修饰处理方法;

实验要求:给出程序和实验结果。

实验内容:

8. 编制MATLAB7.0程序,该程序绘制两条曲线,x的取值在[0,2pi],易pi/10为步长,一条是正弦曲线,一条是余弦曲线,线宽为6个象素,正弦曲线为绿色,余弦曲线为红色,线型分别为实线和虚线。给所绘的两条曲线增添图例,分别为“正弦曲线”和“余弦曲线”。

9. 在同一坐标内,分别用不同线型和颜色绘制曲线y1=0.2e-0.5xcos(4πx) 和y2=2e-0.5xcos(πx),标记两曲线交叉点。

10. 在0≤x≤2 区间内,绘制曲线y1=2e-0.5x和y2=cos(4πx),并给图形添加图形标注。

11.重新绘制第一题所描述的曲线,将正弦曲线和余弦曲线分别画在两个子图中,子图竖向排列。

12、绘制r=sin(t)cos(t)的极坐标图;

13、分别以条形图、阶梯图、杆图和填充图形式绘制曲线y=2sin(x)。 实验程序与结果:

1

x=-2:0.1:2;

y=sin(x).*cos(x); plot(x,y,'-r')

-2

-1.5

-1

-0.5

0.5

1

1.5

2

-0.5-0.4-0.3-0.2-0.100.10.20.30.4

0.5

2

ezplot('x^2/9+y^2/16-1',[-5,5,-5,5]);

x

y

x 2/9+y 2/16-1 = 0

-5

-4

-3

-2

-1

01

2

3

4

5

-5-4-3-2-101234

5

3

x1=-2:0.1:2; x2=-2:0.1:2; y1=sin(x2).*x1; y2=cos(x1).*x2;

plot3(x1,x2,y1,'d',x1,x2,y2,'d')

4

x1=-2:0.1:2;

x2=-2:0.1:2;

y1=x1'*sin(x2); y2=x2'*cos(x1); meshc(y1) hold on meshc(y2)

5

ezplot('x^2/9+y^2/16-1',[-5,5,-5,5]); xlabel('x(-5--5)');

ylabel('y(-5--5)');

title('解曲线')

x(-5--5)

y (-5--5)

解曲线

-5

-4

-3

-2

-1

01

2

3

4

5

-5-4-3-2-101234

5

6

x1=-2:0.1:2; x2=-2:0.1:2; y1=sin(x2).*x1; y2=cos(x1).*x2;

plot3(x1,x2,y1,'d',x1,x2,y2,'d'); text(1,1,'y1=sin(x2).*x1'); text(4,4,'y2=cos(x1).*x2')

7 x=-2:0.1:2;

y=sin(x).*cos(x); plot(x,y,'-r');

axis([-3,3,-1.5,1.5])8

-3

-2-10123

-1.5-1

-0.5

0.5

1

1.5

8

x=0:pi/10:2*pi; y1=sin(x); y2=cos(x);

plot(x,y1,'-g','linewidth',6); hold on

plot(x,y2,'r--','linewidth',6);

legend('sin','cos','location','NorthWest')

1

2

3

4

5

6

7

-1-0.8-0.6-0.4-0.200.20.40.60.81

9

x=linspace(0,2*pi,1000);

y1=0.2*exp(-0.5*x).*cos(4*pi*x); y2=2*exp(-0.5*x).*cos(pi*x); k=find(abs(y1-y2)<1e-2); x1=x(k);

y3=0.2*exp(-0.5*x1).*cos(4*pi*x1); plot(x,y1,x,y2,'dg',x1,y3,'bp')

01234567 10

x=0:0.1:2*pi;

y1=2*exp(-0.5*x);

plot(x,y1)

hold on

y2=cos(4*pi*x);

plot(x,y2);

xlabel('x(0-2\pi)');

text(0.5,1.5,'y1=2*exp(-0.5*x)');

text(0.5,0.5,'y2=cos(4*pi*x)');

legend('y1','y2')

01234567

-1

-0.5

0.51

1.5

2

x(0-2 )

11

x=-2:0.1:2; subplot(2,1,1) y1=sin(x); plot(x,y1,'-r'); subplot(2,1,2); y2=cos(x); plot(x,y2)

-2-1.5-1-0.500.51 1.52

-1-0.500.5

1-2

-1.5-1-0.500.51 1.52

-0.50

0.5

1

12

t=0:0.1:5;

r=sin(t).*cos(t); polar(t,r)

90

270

13

x=0:0.1:10;

y=2*sin(x);

subplot(2,2,1);

bar(x,y);

subplot(2,2,2);

stairs(x,y)

subplot(2,2,3);

stem(x,y);

subplot(2,2,4);

fill(x,y,'g');

-5

051015-2-10120510

-2

-1012-2

-10120510

-2

-1012

相关主题
文本预览
相关文档 最新文档