ImageVerifierCode 换一换
格式:DOCX , 页数:34 ,大小:1.41MB ,
资源ID:6696282      下载积分:12 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/6696282.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(ch5可视化a.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

ch5可视化a.docx

1、ch5可视化a第 5 章 数据和函数的可视化 .1 引导.1.1 离散数据和离散函数的可视化 【例5.1-1】n=(-10:10); y=abs(n); plot(n,y,r.,MarkerSize,20)axis equalgrid on xlabel(n) 图 5.1-1 离散函数的可视化.1.2 连续函数的可视化【例5.1-2】t1=(0:11)/11*pi; t2=(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,

2、1),plot(t1,y1,r.) axis(0,pi,-1,1),title(1)点过少的离散图形)subplot(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),title(3)点密集的离散图形)subplot(2,2,4),plot(t3,y3) axis(0,pi,-1,1),title(4)点足够的连续图形) 图 5.1-2 连续函数的图形表现方法【例5.1-3】N=9;t=0:2*pi/N:2*pi; x=sin(t);

3、y=cos(t); tt=reshape(t,2,(N+1)/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 图 5.1-3 自变量排列次序对连续曲线图形的影响.2 二维曲线和图形.2.1 二维曲线绘制的基本指令plot【例5.2-1】clf t=(0:pi/50:2*pi); k=0.4:0.

4、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 plot(Y)xlabel(row subscript of Y) 图 5.2-1 plot(t,Y)与plot(Y)所绘曲线的区别【例5.2-2】t=(0:pi/100:pi); y1=sin(t)*1,-1; y2=sin(t).*sin(9*t); t3=pi*(0:9)/9; y3=sin(t3).*sin(9*t3); plot(t,y1

5、,r:,t,y2,-bo) hold on plot(t3,y3,s,MarkerSize,10,MarkerEdgeColor,0,1,0,MarkerFaceColor,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,MarkerFaceColor,1,0.8,0) 图5.2-2 属性控制下所绘曲线.2.2 坐标控制和图形标识【例5.2-3】t=0:2*pi/99:2*pi;x=1.15*cos(t);y=3.25*sin(t); sub

6、plot(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 on,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 offtit

7、le(Image and Fill)subplot(2,3,6),plot(x,y),axis tight,box off,title(Tight) 图5.2-3 各种轴控制指令的不同影响【例5.2-4】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) 图 5.2-4 试验标识的图形【例5.2-5】clf;t=6*pi*(0:100)/100;y=1-exp(

8、-0.3*t).*cos(0.7*t);plot(t,y,r-,LineWidth,3) hold ontt=t(find(abs(y-1)0.05);ts=max(tt); plot(ts,0.95,bo,MarkerSize,10) hold offaxis(-inf,6*pi,0.6,inf) set(gca,Xtick,2*pi,4*pi,6*pi,Ytick,0.95,1,1.05,max(y) set(gca,XtickLabel,2*pi;4*pi;6*pi) set(gca,YtickLabel,0.95;1;1.05;max(y) grid ontext(13.5,1.2,f

9、ontsize12alpha=0.3) text(13.5,1.1,fontsize12omega=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(fontsize14it y = 1 - e -alpha tcosomega

10、t) xlabel(fontsize14 bft rightarrow) ylabel(fontsize14 bfy rightarrow) 图 5.2-5 二阶阶跃响应图的标识.2.3 多次叠绘、双纵坐标和多子图【例5.2-6】t=2*pi*(0:20)/20;y=cos(t).*exp(-0.4*t);stem(t,y,g,Color,k);hold onstairs(t,y,:r,LineWidth,3)hold offlegend(fontsize14it stem,fontsize14it stairs)box on 图5.2-6 离散信号的重构【例5.2-7】clf;dx=0.1;

11、x=0:dx:4;y=x.*sin(x);s=cumtrapz(y)*dx; a=plotyy(x,y,x,s,stem,plot); text(0.5,1.5,fontsize14ity=xsinx) sint=fontsize16int_fontsize80 x; ss=fontsize14its=,sint,fontsize14itxsinxdx; text(2.5,3.5,ss) set(get(a(1),Ylabel),String,被积函数 ity=xsinx) set(get(a(2),Ylabel),String,ss) xlabel(x) 图 5.2-7 函数和积分【例5.2

12、-8】clf;t=(pi*(0:1000)/1000);y1=sin(t);y2=sin(10*t);y12=sin(t).*sin(10*t);subplot(2,2,1),plot(t,y1);axis(0,pi,-1,1)subplot(2,2,2),plot(t,y2);axis(0,pi,-1,1)subplot(position,0.2,0.1,0.6,0.40) plot(t,y12,b-,t,y1,-y1,r:)axis(0,pi,-1,1) 图 5.2-8 多子图的布置.2.4 获取二维图形数据的指令ginput【例5.2-9】clfx=0:0.01:1;y=(x+2).x-

13、2;plot(x,y);grid on 图5.2-9 经多次试探后画出的图形图5.2-10 局部放大图x,y=ginput(1); format longx,y x = 0.69828692903537y = -5.884401711382421e-010 .3 三维曲线和曲面.3.1 三维线图指令plot3【例5.3-1】t=(0:0.02:2)*pi;x=sin(t);y=cos(t);z=cos(2*t); plot3(x,y,z,b-,x,y,z,bd)view(-82,58),box onxlabel(x),ylabel(y),zlabel(z)legend(链,宝石,Locatio

14、n,best) 图 5.3-1 宝石项链.3.2 三维曲面/网线图【例5.3-2】clfx=-4:4;y=x; X,Y=meshgrid(x,y); Z=X.2+Y.2; surf(X,Y,Z); colormap(hot) hold onstem3(X,Y,Z,bo) hold offxlabel(x),ylabel(y),zlabel(z)axis(-5,5,-5,5,0,inf) view(-84,21) 图 5.3-2 曲面图和格点.3.3 曲面/网线图的精细修饰【例5.3-3】clf x=-4:4;y=x;X,Y=meshgrid(x,y);Z=X.2+Y.2;surf(X,Y,Z)

15、colormap(jet)subplot(1,3,1),surf(Z),axis offsubplot(1,3,2),surf(Z),axis off,shading flatsubplot(1,3,3),surf(Z),axis off,shading interpset(gcf,Color,w) 图 5.3-4 三种浓淡处理方式faceted/flat/interp的效果比较【例5.3-4】clfsurf(peaks)shading interpalpha(0.5) colormap(summer) 图 5.3-5 半透明薄膜【例5.3-5】clf;X,Y,Z=sphere(40);col

16、ormap(jet) subplot(1,2,1),surf(X,Y,Z),axis equal off,shading interp light (position,0 -10 1.5,style,infinite) lighting phong material shiny subplot(1,2,2),surf(X,Y,Z,-Z),axis equal off,shading flat light;lighting flat light(position,-1,-1,-2,color,y) light(position,-1,0.5,1,style,local,color,w) set(

17、gcf,Color,w) 图 5.3-6 灯光、照明、材质指令所表现的图形.3.4 透视、镂空和裁切【例5.3-6】X0,Y0,Z0=sphere(30); X=2*X0;Y=2*Y0;Z=2*Z0; surf(X0,Y0,Z0); shading interp hold on,mesh(X,Y,Z),colormap(hot) hold off hidden off axis equal,axis off 图5.3-7 剔透玲珑球【例5.3-7】P=peaks(30); P(18:20,9:15)=NaN; surfc(P); colormap(hot)light(position,50,-

18、10,5)material(0.9,0.9,0.6,15,0.4)grid off,box on 图5.3-8 镂方孔的曲面【例5.3-8】clf,x=-8:0.1:8;y=x;X,Y=meshgrid(x,y);ZZ=X.2-Y.2;ii=find(abs(X)6|abs(Y)6); ZZ(ii)=zeros(size(ii); surf(X,Y,ZZ),shading interp;colormap(copper)light(position,0,-15,1);lighting phongmaterial(0.8,0.8,0.5,10,0.5) 图5.3-9 经裁切处理后的图形.4 高维可

19、视化.4.1 二维半图指令pcolor, contour, contourf【例5.4-1】clf;clear;X,Y,Z=peaks(40); n=6; subplot(1,2,1),pcolor(X,Y,Z) shading interpzmax=max(max(Z);zmin=min(min(Z);caxis(zmin,zmax) colorbar hold onC=contour(X,Y,Z,n,k:); clabel(C) hold offsubplot(1,2,2)C,h=contourf(X,Y,Z,n,k:); clabel(C,h) colormap(cool) set(gc

20、f,Color,w) 图 5.4-1 “二维半”指令的演示.4.2 四维表现【例5.4-2】clfx=3*pi*(-1:1/15:1);y=x;X,Y=meshgrid(x,y);R=sqrt(X.2+Y.2)+eps;Z=sin(R)./R;dzdx,dzdy=gradient(Z);dzdr=sqrt(dzdx.2+dzdy.2); dz2=del2(Z); subplot(1,2,1),surf(X,Y,Z,abs(dzdr) shading faceted;colorbar(SouthOutside) brighten(0.6); colormap hsvtitle(No. 1 sur

21、f(X,Y,Z,abs(dzdr)subplot(1,2,2);surf(X,Y,Z,abs(dz2) shading faceted colorbar(NorthOutside) title(No. 2 surf(X,Y,Z,abs(dz2) 图 5.4-2 色彩分别表现函数的径向导数和曲率特征【例5.4-3】 clfx,y,z = meshgrid(-2:.2:2,-2:.25:2,-2:.16:2);v =x.*exp(-x.2-y.2-z.2);xs = -0.7,0.7; ys = 0; zs =0; slice(x,y,z,v,xs,ys,zs) colorbarshading i

22、nterpcolormap hsvxlabel(x),ylabel(y),zlabel(z)title(The color-to-v(x,y,z) mapping)view(-22,39)alpha(0.3) 图 5.4-3 切片图【例 5.4-4】shg;n=2;t=n*pi*(0:0.000005:1);x=sin(t);y=cos(t);plot(x,y,g);axis squarehold on comet(x,y,0.0001)hold off 图5.4-4 用于色图变幻演示的图形【例 5.4-5】ezsurf(x*y,circ);shading flat;view(-18,28)

23、C=summer; CC=C;flipud( C ); colormap(CC)spinmap(30,4) 【例5.4-6】(1)clfx=3*pi*(-1:0.05:1);y=x;X,Y=meshgrid(x,y);R=sqrt(X.2+Y.2)+eps; Z=sin(R)./R;h=surf(X,Y,Z);colormap(jet);axis offn=12;mmm=moviein(n); for i=1:n rotate(h,0 0 1,25); mmm(:,i)=getframe; endclose(2)shg,axis offmovie(mmm,5,10) 【例 5.4-7】(1)t

24、1=(0:1000)/1000*10*pi;x1=cos(t1);y1=sin(t1);z1=-t1;t2=(0:10)/10;x2=x1(end)*(1-t2);y2=y1(end)*(1-t2);z2=z1(end)*ones(size(x2);t3=t2;z3=(1-t3)*z1(end);x3=zeros(size(z3);y3=x3;t4=t2;x4=t4;y4=zeros(size(x4);z4=y4;x=x1 x2 x3 x4;n=length(x);if nargin2 ki=fix(n/2);endy=y1 y2 y3 y4;z=z1 z2 z3 z4;shgplot3(x,

25、y,z,Color,1,0.6,0.4,LineWidth,2.5) axis offh=line(xdata,x(1),ydata,y(1),zdata,z(1),Color,1 0 0,Marker, ., MarkerSize,40,EraseMode,xor);KK=K*n;text(-1,-0.85,-36,倒计数) KK=KK-1;htext=text(-1,-1,-40,int2str(KK);% i=2;j=1;while 1 set(h,xdata,x(i),ydata,y(i),zdata,z(i); drawnow; % pause(0.0005) % i=i+1; KK

26、=KK-1; set(htext,string,int2str(KK) % if nargin=2 & nargout=1 % if(i=ki&j=1);f=getframe(gcf);end % end if in i=1;j=j+1; if jK;break;end endend (2)shgK=2;f=anim_zzy1(2,450); (3)image(f.cdata),axis off 图5.4-5 红球沿下旋螺线运动的瞬间照片.5 图形窗功能简介图 5.5-1 图形窗工具条专用按键【例5.5-1】图5.5-2 个性化的图形(1)t=(0:pi/100:pi); y1=sin(t)*1,-1; y2=sin(t).*sin(9*t); t3=pi*(0:9)/9; y3=zeros(size(t3); plot(t,y1,t,y2,t3,y3) (2)图 5.5-3 编辑工作模式下的图形窗界面(3)图 5.5-4 横坐标上限设置示例(4)图 5.5-5 包络线的设置示例(5)图 5.5

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1