Matlab实验二Word格式文档下载.docx
- 文档编号:5165404
- 上传时间:2023-05-04
- 格式:DOCX
- 页数:24
- 大小:232.43KB
Matlab实验二Word格式文档下载.docx
《Matlab实验二Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《Matlab实验二Word格式文档下载.docx(24页珍藏版)》请在冰点文库上搜索。
(3)MATLAB的绘图修饰
2实验内容
(1)基本二维绘图
1)向量绘图
x=0:
2*pi/100:
2*pi;
y1=sin(2*x);
y2=cos(2*x);
plot(x,y1)
plot(x,y2)
plot(x,y1,x,y2)
plot(x,y1);
holdon;
plot(x,y2);
holdoff;
plot(x'
[y1'
y2'
])
plot(x,y1,'
c:
'
x,y2,'
ro'
)
figure
(1);
figure
(2);
subplot(2,2,1);
subplot(2,2,2);
subplot(2,2,3);
plot(x,y1,x,y1+y2);
subplot(2,2,4);
plot(x,y2,x,y1-y2);
2)函数绘图
fplot('
sin'
[04*pi])
f='
sin(x)'
;
fplot(f,[04*pi])
sin(1/x)'
[0.010.1],1e-3)
[tan(x),sin(x),cos(x)]'
[-2*pi,2*pi,-2*pi,2*pi])
3)符号函数快捷绘图
symsx
f=exp(-0.5*x)*sin(x);
ezplot(f,[0,10])
(2)多种二维绘图
1)半对数绘图
w=logspace(-1,1);
g=20*log10(1./(1+2*w*i));
p=angle(1./(1+2*w*i))*180/pi;
semilogx(w,g);
grid;
Warning:
ImaginarypartsofcomplexXand/orYargumentsignored.
subplot(2,1,2);
semilogx(w,p);
2)极坐标绘图
t=0:
2*2*pi/180:
mo=cos(2*t);
polar(t,mo);
3)直方图
2*pi/8:
y=sin(t);
bar(t,y)
4)离散棒图
stem(t,y)
5)阶梯图
stairs(t,y)
(3)图形注释
y1=dsolve('
D2u+2*Du+10*u=0'
'
Du(0)=1,u(0)=0'
x'
);
y2=dsolve('
D2u+2*Du+10*u=1'
Du(0)=0,u(0)=0'
ezplot(y1,[0,5]);
ezplot(y2,[0,5]);
axis([0,5,-0.1,0.2])
title('
二阶系统时间响应'
xlabel('
时间t'
ylabel('
响应幅值y'
gtext('
零输入响应'
零状态响应'
(4)三维绘图
1)三维线图
pi/50:
10*pi;
plot3(sin(t),cos(t),t);
comet3(sin(t),cos(t),t);
2)单变量高度网线图
Z2=[11;
1-1];
Z4=[Z2Z2;
Z2-Z2];
Z8=[Z4Z4;
Z4-Z4];
Mesh(Z8);
3)3变量马鞍面网线图
x=-4:
0.5:
4,y=x;
[X,Y]=meshgrid(x,y);
Z=X.^2-Y.^2;
Mesh(X,Y,Z);
x=
Columns1through9
-4.0000-3.5000-3.0000-2.5000-2.0000-1.5000-1.0000-0.50000
Columns10through17
0.50001.00001.50002.00002.50003.00003.50004.0000
Couldnotfindanexact(case-sensitive)matchfor'
Mesh'
.
D:
\MATLAB\CD1\UP\toolbox\matlab\graph3d\mesh.misacase-insensitivematchandwillbeusedinstead.
Youcanimprovetheperformanceofyourcodebyusingexact
namematchesandwethereforerecommendthatyouupdateyour
usageaccordingly.Alternatively,youcandisablethiswarningusing
warning('
off'
MATLAB:
dispatcher:
InexactMatch'
).
4)圆锥面网线图
t1=0:
0.1:
0.9;
t2=1:
2;
r=[t1-t2+2];
[X,Y,Z]=cylinder(r,40);
5)视角修饰
[X,Y,Z]=cylinder(r,30);
mesh(X,Y,Z);
view(0,0);
view(-20,20);
view(-30,30);
view(-40,40);
实验心得:
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Matlab 实验