版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、二维数据可视化 4 MATLAB绘图原理 MATLAB根据给出的采样点,自动地进行插值计算,进而绘制出曲线。 只是真实曲线的近似。采样点不够多时,不能真实反映原函数。 clc;clear all; x1=0:pi/10:pi; x2=0:pi/100:pi; y1=sin(x1).*sin(9*x1); y2=sin(x2).*sin(9*x2); subplot(2,1,1),plot(x1,y1) axis(0,pi,-1,1),title(a)y=sin(x)sin(9x)的图形,采样点较少,11个点) subplot(2,1,2),plot(x2,y2) axis(0,pi,-1,1)
2、,title(b)y=sin(x)sin(9x)的图形,采样点较多,101个点) 4 plot(x,y) clc;clear all; x=0.01:0.3:2*pi; y=cos(x+0.5)+2; plot(x,y) clc;clear all; x=0:0.1:6; y=sin(x); plot(x,y) plot(x,y,s) 线型 -实线(默认) -虚线 :点线 -.点划线等等 采样点 +加号 o空心圆 *星号 s正方形 h六边形等等 颜色 r红色 g绿色 b蓝色 k黑色等等 clc;clear all; x=0:0.1:6; y=sin(x); plot(x,y,-og*) clc
3、;clear all; x=0:0.1:6; y=sin(x); plot(x,y) plot(x,y,s) 线型 -实线(默认) -虚线 :点线 -.点划线等等 采样点 +加号 o空心圆 *星号 s正方形 h六边形 d菱形等等 颜色 r红色 g绿色 b蓝色 k黑色等等 clc;clear all; x=0.01:0.3:2*pi; y=cos(x+0.5)+2; plot(x,y,r-.*) clc;clear all; x=0.01:0.3:2*pi; y=cos(x+0.5)+2; plot(x,y) 生成子图subplot clc;clear all; x=0:0.1:6; y=sin
4、(x); subplot(2,1,1) plot(x,y) subplot(2,1,2) plot(x,y,-og) clc;clear all; x=0.01:0.3:2*pi; y=cos(x+0.5)+2; subplot(2,1,1) plot(x,y) subplot(2,1,2) plot(x,y,r-.*) 生成子图subplot plot(x,y,s) LineWidth 线宽 MarkerEdgeColor 采样点边框的颜色 MarkerEdgeColor 采样点内部填充颜色 MarkerSize 采样点大小 clc;clear all; x=-pi:pi/10:pi; y=
5、tan(sin(x)-sin(tan(x); plot(x,y,-rs,. LineWidth,2,. MarkerEdgeColor,k,. MarkerFaceColor,g,. MarkerSize,10) %-虚线 s正方形 r红色 k黑色 g绿色 clc;clear all; x=-pi:pi/10:pi; y=tan(sin(x)-sin(tan(x); plot(x,y,-rs) 4 开启网格grid on grid off clc;clear all; x=0.01:0.01:2*pi; y=sin(x); plot(x,y) grid on clc;clear all; x=
6、0.01:0.01:2*pi; y=sin(x); plot(x,y) grid off clc;clear all; x=0.01:0.01:2*pi; y=sin(x); plot(x,y) %默认为不画网格线 4 关闭边框box off box on clc;clear all; x=0.01:0.01:2*pi; y=sin(x); plot(x,y) box off clc;clear all; x=0.01:0.01:2*pi; y=sin(x); plot(x,y) box on clc;clear all; x=0.01:0.01:2*pi; y=sin(x); plot(x,
7、y) %默认为边框开启 图像标注title xlabel ylabel legend text clc;clear all; x=0:pi/10:2*pi; y=sin(x); plot(x,y,-rs) title(函数图像) xlabel(x轴) ylabel(y轴) legend(sin(x) text(0.8*pi,sin(3*pi/4),leftarrow y=sin(x) 坐标轴设置axis clc;clear all; x=0:pi/10:2*pi; y=sin(x); plot(x,y,-rs) title(函数图像) xlabel(x轴) ylabel(y轴) legend(
8、sin(x) text(0.8*pi,sin(3*pi/4),leftarrow y=sin(x) axis equal 坐标轴设置set clc;clear all; x=0:pi/10:2*pi; y=sin(x); plot(x,y,-rs) title(函数图像) xlabel(x轴) ylabel(y轴) legend(sin(x) text(0.8*pi,sin(3*pi/4),leftarrow y=sin(x) set(gca,Xtick,-pi:pi/2:2*pi) set(gca,Ytick,-1:0.5:1) set(gca,XtickLabel,-pi,-pi/2,0,
9、pi/2,pi) 4 plot(x,y1,s1,x,y2,s2) clc;clear all; x=-pi:pi/10:pi; y1=sin(x); y2=cos(x); plot(x,y1,r:*,x,y2,g-.v) set(gca,Xtick,-pi:pi/2:pi) set(gca,XtickLabel,-pi,-pi/2,0,pi/2,pi) legend(sin(x),cos(x) 4 plot(x,y1,s1,x,y2,s2,x,y3,s3) clc;clear all; x=-pi:pi/10:pi; y1=sin(x+2); y2=cos(x-1); y3=sin(x).*c
10、os(x); plot(x,y1,r:*,x,y2,g-.v,x,y3,k-s) set(gca,Xtick,-pi:pi/2:pi) set(gca,XtickLabel,-pi,-pi/2,0,pi/2,pi) set(gca,Ytick,-1:0.5:1) legend(sin(x+2),cos(x-1),sin(x)cos(x) 4 plot(x1,y1,s1,x2,y2,s2) clc;clear all; x1=-pi:pi/10:pi; y1=sin(x1); x2=0:pi/10:2*pi; y2=cos(x2); plot(x1,y1,r:*,x2,y2,g-.v) set(
11、gca,Xtick,-pi:pi/2:2*pi) set(gca,XtickLabel,-pi,-pi/2,0,pi/2,pi,3pi/2,2pi) set(gca,Ytick,-1:0.5:1) text(-pi+0.3,0,leftarrow y=sin(x) text(3*pi/2+0.3,0,leftarrow y=cos(x) 4 plot(x1,y1,s1,x2,y2,s2,x3,y3,s3) clc;clear all; x1=-pi:pi/10:pi; y1=sin(x1); x2=-1:1/10:1; y2=asin(x2); x3=-2:1:2; y3=x3; plot(x
12、1,y1,x2,y2,x3,y3) legend(sin(x),asin(x),x) 4 开启叠加图hold on hold off clc;clear all; x=-pi:pi/10:pi; plot(x,sin(x),r:) hold on plot(x,cos(x),b-) plot(x,cos(x),b-) hold off plot(x,cos(x),b-) %默认为叠加关闭 4 fplot(fun,lims,tol) clc;clear all; x=0:0.01:1; y=cos(tan(pi*x); subplot(1,2,1); plot(x,y,-b); title(采用
13、函数plot绘图); subplot(1,2,2); fplot(cos(tan(pi*x),0 1,1e-4); title(采用函数fplot绘图); 4 ezplot(fun,xmin,xmax) clc;clear all; subplot(2,1,1) ezplot(sin(x) subplot(2,1,2) ezplot(sin(x),-2*pi,2*pi) 4 ezplot(fun,xmin xmax ymin ymax) clc;clear all; subplot(2,1,1) ezplot(x.2.*sin(x+y.2)+y2*exp(x+y)+5*cos(x.2+y) s
14、ubplot(2,1,2) ezplot(x.2.*sin(x+y.2)+y2*exp(x+y)+5*cos(x.2+y),-2*pi 2*pi -2*pi 2*pi) 4 ezplot(x,y,tmin tmax) clc;clear all; subplot(1,2,1) ezplot(2*(cos(t).3,2*(sin(t).3) subplot(1,2,2) ezplot(2*(cos(t).3,2*(sin(t).3,0 2*pi) 4 ezplot(fun,xmin,xmax) ezplot(fun,xmin xmax ymin ymax) ezplot(x,y,tmin tma
15、x) clc;clear all; subplot(2,2,1) ezplot(sin(x.3/x+1) subplot(2,2,2) ezplot(x.*sin(x.2-x-sin(y) subplot(2,1,2) ezplot(sin(t.2+t),sin(sin(t)*4.5) 4 plotyy(x,y1,x,y2) clc;clear all; x=0.1:0.1:2*pi; y1=sin(x); y2=2*x; plotyy(x,y1,x,y2) legend(sin(x),2x) 4 polar(theta,rho,s) clc;clear all; theta=0:0.1:2*
16、pi; rho=sin(2*theta).*cos(2*theta); polar(theta,rho,-r*) clc;clear all; theta=0:pi/10:4*pi; rho=1+theta; polar(theta,rho,-r*) 三维数据可视化 4 plot3(x,y,z,s) clc;clear all; t=0:pi/25:20*pi; x=t.*sin(t); y=t.*cos(t); z=t; plot3(x, y, z) grid on clc;clear all; t=0:0.02*pi:2*pi; x=sin(t); y=cos(t); z=cos(2*t)
17、; plot3(x,y,z,b-,x,y,z,bd) grid on 4 meshgrid产生平面区域的网格矩阵点 clc;clear all; x=-2*pi:2*pi; y=0*pi:4*pi; X,Y=meshgrid(x,y); plot(X,Y,o) 4 plot3(x,y,z) clc;clear all; x,y=meshgrid(-3:0.1:3); z=5*x.2-y.2+3; plot3(x,y,z) grid on 4 mesh(x,y,z) clc;clear all; x,y=meshgrid(-10:0.1:10); z=-x.2-y.2+200; mesh(x,y
18、,z) clc;clear all; x,y=meshgrid(-3:0.1:3); z=5*x.2-y.2+3; mesh(x,y,z) 4 mesh(x,y,z) clc;clear all; x,y=meshgrid(-3:0.1:3); z=peaks(x,y); mesh(x,y,z) %z=peaks(x,y)=3*(1-x).2.*exp(-(x.2)-(y+1).2)-10*(x/5-x.3-y.5).*exp(-x.2-y.2) -1/3*exp(-(x+1).2-y.2) 4 plot(x,y,z) mesh(x,y,z) clc;clear all; x,y=meshgr
19、id(-3:0.1:3); z=5*x.2-y.2+3; subplot(1,2,1) plot3(x,y,z) grid on subplot(1,2,2) mesh(x,y,z) 4 meshc(x,y,z) meshz(x,y,z) clc;clear all; x,y=meshgrid(-3:0.1:3); z=peaks(x,y); subplot(1,2,1) meshc(x,y,z) subplot(1,2,2) meshz(x,y,z) 4 waterfall(x,y,z) clc;clear all; x,y=meshgrid(-3:0.1:3); z=peaks(x,y); subplot(1,2,1) waterfall(x,y,z) xlabel(x) ylabel(y) zlabel(z) subplot(1,2,2) waterfall(x,y,z) xlabel(x) ylabel(y) zlabel(z) 4 surf(x,y,z) clc;clear all; x,y=meshgrid(-10:0.1:10); z=-x.2-y.2+200; surf(x,y,z) clc;clear all; x,y=me
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 江苏省射阳实验初中达标名校2025-2026学年初三化学试题全国三卷模拟卷1含解析
- 2026年直驱转台与高精度反馈系统提升联动平顺性
- 2026年出口退运货物补发RCEP原产地证操作流程
- 2026年拖拉机全面进入动力换挡动力换向时代技术解析
- 2025年临床执业医师《妇产科学》测试卷
- 服装设计师招聘面试问题详解
- 文化产品如图书、音乐销售分析
- 从工作角度解读:如何在邮件银行提高系统效率
- 互联网公司活动推广运营总监的招聘与面试技巧
- 商场大堂经理工作手册与日程安排
- 铃儿响叮当的变迁合唱简谱
- 麻精药品信息化管理系统需求说明
- 全过程工程咨询实施投标方案
- 镇墩稳定计算
- parp抑制剂研究进展 课件
- 《水工钢结构》试题及答案1783
- 实习协议书电子电子版(2篇)
- 三级医院评审标准(2023年版)实施细则
- 江苏专转本计算机资料汇编
- GA/T 2002-2022多道心理测试通用技术规程
- 片区更新改造总体规划项目建议书
评论
0/150
提交评论