matlab图形可视化-课下练习题

上传人:ji****72 文档编号:37521733 上传时间:2018-04-17 格式:DOC 页数:23 大小:9.45MB
返回 下载 相关 举报
matlab图形可视化-课下练习题_第1页
第1页 / 共23页
matlab图形可视化-课下练习题_第2页
第2页 / 共23页
matlab图形可视化-课下练习题_第3页
第3页 / 共23页
matlab图形可视化-课下练习题_第4页
第4页 / 共23页
matlab图形可视化-课下练习题_第5页
第5页 / 共23页
点击查看更多>>
资源描述

《matlab图形可视化-课下练习题》由会员分享,可在线阅读,更多相关《matlab图形可视化-课下练习题(23页珍藏版)》请在金锄头文库上搜索。

1、1第 5 章 数据和函数的可视化数据和函数的可视化课下练习题课下练习题5.1引导引导5.1.1离散数据和离散函数的可视化离散数据和离散函数的可视化【例 5.1-1】 用图形表示离散函数 y=n. n=(-10:10); y=abs(n); plot(n,y,r.,MarkerSize,20) axis equal grid on xlabel(n) -10-8-6-4-20246810-2024681012n图 5.1-1 离散函数的可视化5.1.2连续函数的可视化连续函数的可视化【例 5.1-2】用图形表示连续调制波形 y=sin(t)sin(9t)。 t1=(0:11)/11*pi; t2

2、=(0:400)/400*pi; t3=(0:50)/50*pi; y1=sin(t1).*sin(9*t1); y2=sin(t2).*sin(9*t2); y3=sin(t3).*sin(9*t3); subplot(2,2,1),plot(t1,y1,r.) axis(0,pi,-1,1),title(1)点过少的离散图形点过少的离散图形)2subplot(2,2,2),plot(t1,y1,t1,y1,r.) axis(0,pi,-1,1),title(2)点过少的连续图形点过少的连续图形) subplot(2,2,3),plot(t2,y2,r.) axis(0,pi,-1,1),t

3、itle(3)点密集的离散图形点密集的离散图形) subplot(2,2,4),plot(t3,y3) axis(0,pi,-1,1),title(4)点足够的连续图形点足够的连续图形) 0123-1-0.500.51(1) 0123-1-0.500.51(2) 0123-1-0.500.51(3) 0123-1-0.500.51(4) 图 5.1-2 连续函数的图形表现方法【例 5.1-3】绘制奇数正多边形及圆。 N=9; %多边形边数多边形边数 t=0:2*pi/N:2*pi;%递增排列的自变量递增排列的自变量 x=sin(t);y=cos(t); tt=reshape(t,2,(N+1)

4、/2);%把行向量重排成二维数组把行向量重排成二维数组 tt=flipud(tt);%把二维数组上下两排调换把二维数组上下两排调换 tt=tt(:);%获得变序排列的自变量获得变序排列的自变量 xx=sin(tt);yy=cos(tt); subplot(1,2,1),plot(x,y) title(1) 正常排序图形正常排序图形),axis equal off,shg subplot(1,2,2),plot(xx,yy) title(2) 非正常排序图形非正常排序图形),axis equal off,shg 3(1) (2) 图 5.1-3 自变量排列次序对连续曲线图形的影响“绘制连续曲线时

5、,自变量必须按照递增或递减的次序排列绘制连续曲线时,自变量必须按照递增或递减的次序排列”5.2二维曲线和图形二维曲线和图形5.2.1二维曲线绘制的基本指令二维曲线绘制的基本指令 plot【例 5.2-1】plot(t,Y)plot(Y)所绘曲线的区别;“线宽”属性的设置。 clf t=(0:pi/50:2*pi); k=0.4:0.1:1; Y=cos(t)*k; subplot(1,2,1) plot(t,Y,LineWidth,1.5) title(By plot(t,Y) xlabel(t) subplot(1,2,2) plot(Y,LineWidth,1.5) title(By pl

6、ot(Y) xlabel(row subscript of Y) 402468-1-0.8-0.6-0.4-0.200.20.40.60.81By plot(t,Y)t050100150-1-0.8-0.6-0.4-0.200.20.40.60.81By plot(Y)row subscript of Y图 5.2-1 plot(t,Y)与 plot(Y)所绘曲线的区别【例 5.2-2】用图形表示连续调制波形 y=sin(t)sin(9t)及其包络线。 t=(0:pi/100:pi); y1=sin(t)*1,-1; y2=sin(t).*sin(9*t); t3=pi*(0:9)/9; y3

7、=sin(t3).*sin(9*t3); plot(t,y1,r:,t,y2,-bo) hold on %plot(t3,y3,s,MarkerSize,10,MarkerEdgeColor,0,1,0,MarkerFace Color,1,0.8,0) %axis(0,pi,-1,1) hold off %plot(t,y1,r:,t,y2,- bo,t3,y3,s,MarkerSize,10,MarkerEdgeColor,0,1,0,MarkerFaceCo lor,1,0.8,0) 500.511.522.53-1-0.8-0.6-0.4-0.200.20.40.60.81图 5.2-

8、2 属性控制下所绘曲线5.2.2坐标控制和图形标识坐标控制和图形标识【例 5.2-3】观察各种轴控制指令的影响。演示采用长轴 3.25,短轴 1.15 的椭圆。 t=0:2*pi/99:2*pi; x=1.15*cos(t);y=3.25*sin(t); subplot(2,3,1),plot(x,y),axis normal,grid on, title(Normal and Grid on) subplot(2,3,2),plot(x,y),axis equal,grid on,title(Equal) subplot(2,3,3),plot(x,y),axis square,grid o

9、n,title(Square) subplot(2,3,4),plot(x,y),axis image,box off,title(Image and Box off) subplot(2,3,5),plot(x,y),axis image fill,box off title(Image and Fill) subplot(2,3,6),plot(x,y),axis tight,box off,title(Tight) 6-202-4-2024Normal and Grid on-202-202Equal-202-4-2024Square-101-202Image and Box off-1

10、01-1-0.500.51Image and Fill-101-202Tight图 5.2-3 各种轴控制指令的不同影响【例 5.2-4】绘制 y=sin(t)曲线,并在图上标出极大值的位置。 clf;t=0:pi/50:2*pi; y=sin(t); plot(t,y) axis(0,2*pi,-1.2,1.2) text(pi/2,1,fontsize16leftarrowitsin(t)fontname隶书隶书极大值极大值) title(y=sin(t) xlabel(t) ylabel(y) 70123456-1-0.8-0.6-0.4-0.200.20.40.60.81sin(t)极

11、大值y=sin(t)ty图 5.2-4 试验标识的图形【例例】 绘制二阶系统阶跃响应绘制二阶系统阶跃响应,)cos(1teyt7 . 0, 3 . 0 曲线,综合运用图形标识功能。曲线,综合运用图形标识功能。 clf;t=6*pi*(0:100)/100; y=1-exp(-0.3*t).*cos(0.7*t); plot(t,y,r-,LineWidth,3) hold on tt=t(find(abs(y-1)0.05);ts=max(tt); %寻找镇定时间,此后响应与寻找镇定时间,此后响应与 1 的距离不的距离不 会会%超过超过 0.05 plot(ts,0.95,bo,MarkerS

12、ize,10) %镇定点位置镇定点位置 hold off axis(-inf,6*pi,0.6,inf) %横下及纵上限自动生成横下及纵上限自动生成 set(gca,Xtick,2*pi,4*pi,6*pi,Ytick,0.95,1,1.05,max(y) %设置设置 X %Y 轴坐标分刻线轴坐标分刻线 set(gca,XtickLabel,2*pi;4*pi;6*pi)%设置刻度点标识设置刻度点标识set(gca,YtickLabel,0.95;1;1.05;max(y) grid on text(13.5,1.2,fontsize12alpha=0.3) text(13.5,1.1,fon

13、tsize12omega=0.7) cell_string1=fontsize12uparrow; cell_string2=fontsize16 fontname隶书隶书镇定时间镇定时间; cell_string3=fontsize6 ;%构成数组,用于多行注释构成数组,用于多行注释 cell_string4=fontsize14rmt_s = num2str(ts); text(ts,0.85,cell_string,Color,b,HorizontalAlignment,Center) %对镇定点采用蓝色和中心对准方式进行多行注释对镇定点采用蓝色和中心对准方式进行多行注释 title(f

14、ontsize14it y = 1 - e -alpha tcosomegat) xlabel(fontsize14 bft rightarrow) ylabel(fontsize14 bfy rightarrow) 82*pi4*pi6*pi0.9511.05max(y)=0.3=0.7镇定时间ts = 9.6133y = 1 - e - tcostt y 图 5.2-5 二阶阶跃响应图的标识5.2.3多次叠绘、双纵坐标和多子图多次叠绘、双纵坐标和多子图【例 5.2-6】利用 hold 绘制离散信号通过零阶保持器后产生的波形。 t=2*pi*(0:20)/20; y=cos(t).*exp(

15、-0.4*t); stem(t,y,g,Color,k); hold on stairs(t,y,:r,LineWidth,3) hold off legend(fontsize14it stem,fontsize14it stairs) box on 901234567-0.4-0.200.20.40.60.81stemstairs图 5.2-6 离散信号的重构【例】画出函数和积分在区间0,4上的曲线。xxysinxdxxsx 0)sin(clf;dx=0.1;x=0:dx:4;y=x.*sin(x); s=cumtrapz(y)*dx;%梯形法求累计积分梯形法求累计积分 a=plotyy(x,y,x,s,stem,plot);%分别采用杆图和线图绘制在同一张图分别采用杆图和线图绘制在同一张图 %上,将轴对象句柄赋给上,将

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号