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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

Matlab 图形基础.docx

1、Matlab 图形基础 实验三 Matlab图形基础一、 目的:1、 了解交互式绘图方法;2、 学会能用二维及三维指令绘图;3、 掌握图形的保存和输出;一、 实验原理:1、 准备需要绘制在Matlab图形窗口的数据;2、 创建图形窗口,并且选择绘制数据的区域。一个Matlab图形窗口可以包含多个绘图区域;3、 绘制图形或者曲线;4、 设置曲线的属性,例如线型,线宽;5、 设置绘图区域的属性,并且添加数据网格线;6、 为绘制的图形添加标题、轴标签或者标注文本等;7、 打印或者导出图形。二、 实验仪器及软件: 电脑、Matlab编程软件三、 实验数据:%交互式绘图 randn(state,27)

2、startprice=40; f1=0.0015*randn(200,1)+0.0003; x1=startprice;1+f1; price1=cumprod(x1); t=(1:length(price1); randn(state,7) f2=0.0015*randn(200,1)+0.0003; x2=startprice;1+f2; prices2=cumprod(x2);Price1变量线图可视化结果:Prices2变量线图可视化结果:综合对比: 上图生成的M函数文件:function createfigure(y1, y2)%CREATEFIGURE(Y1,Y2)% Y1: ve

3、ctor of y data% Y2: vector of y data% Auto-generated by MATLAB on 06-May-2013 09:10:35% Create figurefigure1 = figure(PaperPosition,0.6345 6.345 20.3 15.23,PaperSize,20.98 29.68); % Create axesaxes1 = axes(Parent,figure1);xlim(axes1,0 200);xlabel(axes1,Time);ylabel(axes1,Prices);hold(axes1,all); % C

4、reate plotplot1 = plot(y1,. DisplayName,price1,. YDataSource,price1); % Create plotplot2 = plot(y2,. DisplayName,prices2,. YDataSource,prices2); % Create textarrowannotation1 = annotation(. figure1,textarrow,. 0.6071 0.6804,0.2619 0.3571,. String,Price1); % Create textarrowannotation2 = annotation(.

5、 figure1,textarrow,. 0.6411 0.7429,0.6333 0.5714,. String,Prices2); x=0:pi/100:2*pi; y=exp(-0.5*x).*sin(2*pi*x+pi/4); plot(x,y); title(绘制曲线); xlabel(independent variable X); ylabel(independent variable Y);plot(x,y,x,y+1,x,y-1); B=pascal(5) %利用plot函数绘制矩阵数据B = 1 1 1 1 1 1 2 3 4 5 1 3 6 10 15 1 4 10 20

6、 35 1 5 15 35 70 plot(B); title(绘制矩阵数据); x=(0:pi/100:2*pi); y1=2*exp(-0.5*x)*1,-1; y2=2*exp(-0.5*x).*sin(2*pi*x); x1=(0:12)/2; y3=2*exp(-0.5*x1).*sin(2*pi*x1); plot(x,y1,g:,x,y2,b-,x1,y3,rp); x=(0:pi/100:2*pi); y1=2*exp(-0.5*x)*1,-1; y2=2*exp(-0.5*x).*sin(2*pi*x); x1=(0:12)/2; y3=2*exp(-0.5*x1).*sin

7、(2*pi*x1); plot(x,y1,g:,x,y2,b-,x1,y3,rp); x1=0:pi/100:2*pi; x2=0:pi/100:3*pi; y1=exp(-0.5*x1).*sin(2*pi*x1); y2=1.5*exp(-0.1*x2).*sin(x2); plotyy(x1,y1,x2,y2); x=(0:pi/100:2*pi); y1=2*exp(-0.5*x)*1,-1; y2=2*exp(-0.5*x).*sin(2*pi*x); x1=(0:12)/2; y3=2*exp(-0.5*x1).*sin(2*pi*x1); plot(x,y1,g:,x,y2,b-

8、,x1,y3,rp); title(Curve and Envelope line); xlabel(independent variable X); ylabel(independent variable Y); text(2.8,0.5,Envelope line); text(0.5,0.5,Curve y); text(1.4,0.1,Discrete data point); legend(Envelpoe line,Envelope line,Curve y,discrete data point) %加图列 x=(0:pi/100:2*pi); y1=2*exp(-0.5*x)*

9、1,-1;y2=2*exp(-0.5*x).*sin(2*pi*x); plot(x,y1,b:); axis(0,2*pi,-2,2); hold on; plot(x,y2,k); grid on; %加网格线 box off; %不加坐标边框 hold off; %关闭图形保持tex_examp.m %M文件function tex_examp %TEX_EXAMP 在文本注释中使用特殊文本alpha=-0.5; beta=3; A=50; t=0:0.01:10; y=A*exp(alpha*t).*sin(beta*t); plot(t,y); %添加特殊文本注释title(font

10、name隶书fontsize16隶书fontnameImpactImpact)xlabel(上标and_下标)ylabel(Somebf粗体rm and some it斜体)txt=y=itAealphaxsin(betaitt),. itArm,=,num2str(A),. alpha=,num2str(alpha),. beta=,num2str(beta);text(2,22,txt);tex_exampAnswer.mx=linspace(0,2*pi,60);y=sin(x);z=cos(x);t=sin(x)./(cos(x)+eps);ct=cos(x)./(sin(x)+eps

11、);subplot(2,2,1);plot(x,y);title(sin(x);axis(0,2*pi,-1,1);subplot(2,2,2);plot(x,z);title(cos(x);axis(0,2*pi,-1,1);subplot(2,2,3);plot(x,t);title(tangent(x);axis(0,2*pi,-40,40);subplot(2,2,4);plot(x,ct);title(cotangent(x);axis(0,2*pi,-40,40);Question.mx=linspace(0,2*pi,60);y=sin(x);z=cos(x);t=sin(x).

12、/(cos(x)+eps);ct=cos(x)./(sin(x)+eps);subplot(2,2,1);stairs(x,y);title(sin(x)-1);axis(0,2*pi,-1,1);subplot(2,1,2);stem(x,y);title(sin(x)-2);axis(0,2*pi,-1,1);subplot(4,4,3);plot(x,y);title(sin(x);axis(0,2*pi,-1,1);subplot(4,4,4);plot(x,y);title(cos(x);axis(0,2*pi,-1,1);subplot(4,4,7);plot(x,t);title

13、(tangent(x);axis(0,2*pi,-40,40);subplot(4,4,8);plot(x,ct);title(cotangent(x);axis(0,2*pi,-40,40);circle.mx=0:0.35:7;y=2*exp(-0.4*x);subplot(2,2,1);bar(x,y,g);title(bar(x,y,g);axis(0,7,0,2);subplot(2,2,2);fill(x,y,r);title(fill(x,y,r);axis(0,7,0,2);subplot(2,3,4);stairs(x,y,b);title(stairs(x,y,b);axi

14、s(0,7,0,2);subplot(2,3,5);stem(x,y,k);title(stem(x,y,k);axis(0,7,0,2);subplot(2,3,6);area(x,y);title(area(x,y);axis(0,7,0,2); theta=0:0.01:2*pi; rho=sin(3*theta).*cos(3*theta); %极坐标绘图 polar(theta,rho,r); x=0:0.1:10; y=12*x.*x; subplot(2,2,1);plot(x,y);title(plot(x,y);grid on; subplot(2,2,2);semilogx

15、(x,y);title(semilogx(x,y);grid on; subplot(2,2,3);semilogx(x,y);title(semilogx(x,y);grid on; subplot(2,2,4);loglog(x,y);title(loglog(x,y);grid on;Myf.mfunction y=myf(x)y=cos(tan(pi*x);fplot(myf,-0.2,1.2,1e-4) subplot(1,2,1); pie(7,17,23,19,5); title(饼图);legend(优秀,良好,中等,及格,不及格); subplot(1,2,2); compa

16、ss(3+2i,4.5-i,-1.5+5i);title(相量图); t=0:pi/50:2*pi; x=8*cos(t);y=4*sqrt(2)*sin(t);z=-4*sqrt(2)*sin(t); plot3(x,y,z,p); title(Line in 3-D Space);text(0,0,0,origin); xlabel(X),ylabel(Y);zlabel(Z);grid; x=5:29;y=14:35; x,y=meshgrid(x,y); %在5:29*14,35区域生成网格坐标 z=2*x+5*y; k=find(z=126); x(k),y(k)ans = 8 13

17、 18 23 28ans =22 20 18 16 14 x=0:0.1:2*pi;x,y=meshgrid(x);z=sin(y).*cos(x); mesh(x,y,z);xlabel(x-axis),ylabel(y-axis),zlabel(z-axis);title(mesh); x=0:0.1:2*pi;x,y=meshgrid(x);z=sin(y).*cos(x); surf(x,y,z);xlabel(x-axis),ylabel(y-axis),zlabel(z-axis);title(surf); x=0:0.1:2*pi;x,y=meshgrid(x);z=sin(y)

18、.*cos(x); plot3(x,y,z);xlabel(x-axis),ylabel(y-axis),zlabel(z-axis);title(plot3);grid; x,y=meshgrid(-10:0.5:10); z=sin(sqrt(x.2+y.2)./sqrt(x.2+y.2+eps); subplot(2,2,1); meshc(x,y,z); title(meshc(x,y,z); subplot(2,2,2); meshz(x,y,z); title(meshz(x,y,z); subplot(2,2,3); surfc(x,y,z); title(surfc(x,y,z

19、); subplot(2,2,4); surfl(x,y,z); title(surfl(x,y,z); t=0:pi/20:2*pi; x,y,z=cylinder(2+sin(t),30); subplot(1,3,1); surf(x,y,z); subplot(1,3,2); x,y,z=sphere; surf(x,y,z); subplot(1,3,3); x,y,z=peaks(30); meshz(x,y,z); subplot(2,2,1); bar3(magic(5); subplot(2,2,2); y=3*sin(0:pi/10:2*pi); stem3(y); sub

20、plot(2,2,3); pie3(2347,1827,2043,3025); subplot(2,2,4); fill3(rand(3,6),rand(3,6),rand(3,6),r); subplot(1,2,1); x,y,z=peaks; waterfall(x,y,z); xlabel(x-axis),ylabel(y-axis),zlabel(z-axis); title(waterfall of peaks); subplot(1,2,2); contour3(x,y,z,12,k); %其中12代表高度的等级数 xlabel(x-axis),ylabel(y-axis),zl

21、abel(z-axis); title(contour3 of peaks);&:三维图形精细处理 subplot(2,2,1);mesh(peaks); view(-37.5,30); title(azimuth=-37.5,elevation=30); subplot(2,2,2);mesh(peaks); view(0,90); title(azimuth=0,elevation=90); subplot(2,2,3);mesh(peaks); view(90,0); title(azimuth=90,elevation=0); subplot(2,2,4);mesh(peaks); v

22、iew(-7,-10); title(azimuth=-7,elevation=-10); z=peaks(20);colormap(copper); subplot(1,3,1);surf(z); subplot(1,3,2);surf(z);shading flat; subplot(1,3,3);surf(z);shading interp; x=0:0.1:2*pi;x,y=meshgrid(x);z=sin(y).*cos(x); surf(x,y,z);xlabel(x-axis),ylabel(y-axis),zlabel(z-axis);title(surf); x=0:0.1

23、:2*pi;x,y=meshgrid(x);z=sin(y).*cos(x); I,J=find(z0.2); for ii=1:length(I) z(I(ii),J(ii)=NaN;end surf(x,y,z);&:图形的保存和输出function h = peakfile% This function was created by saveas(.,mfig), or print -dmfile.% It loads an HG object saved in binary format in the FIG-file of the% same name. NOTE: if you w

24、ant to see the old-style M code% representation of a saved object, previously created by print -dmfile,% you can obtain this by using saveas(.,mmat). But be advised that the% M-file/MAT-file format does not preserve some important information due% to limitations in that format, including Application

25、Data stored using% setappdata. Also, references to handles stored in UserData or Application-% Data will no longer be valid if saved in the M-file/MAT-file format.% ApplicationData and stored handles (excluding integer figure handles)% are both correctly saved in FIG-files.%load the saved objectpath, name = fileparts(which(mfilename);figname = fullfile(path, name .fig);if (exist(figname,file), open(figname), else open(name .fig), endif nargout 0, h = gcf; end surf(peaks(30) saveas(gcf,peakfile,m) peakfile open(peakfile.fig)习题: x=0:1:100; y=x.*x.*x+x+1; plot(x,y)

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

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