三matlab绘图件.pptVIP

  • 1
  • 0
  • 约7.12千字
  • 约 34页
  • 2018-06-03 发布于上海
  • 举报
三matlab绘图件

二、 二维统计分析图 在MATLAB中,二维统计分析图形很多,常见的有条形图、阶梯图、杆图和填充图等, 所采用的函数分别是: bar(x,y,选项) stairs(x,y,选项) stem(x,y,选项) fill(x1,y1,选项1,x2,y2,选项2,…) 第32页/共34页 例3-14 分别以条形图、阶梯图、杆图和填充图形式绘制曲线y=2sin(x)。 程序如下: x=0:pi/10:2*pi; y=2*sin(x); subplot(2,2,1);bar(x,y); title(bar(x,y));axis([0,7,-2,2]); subplot(2,2,2);stairs(x,y,b); title(stairs(x,y,b));axis([0,7,-2,2]); subplot(2,2,3);stem(x,y,k); title(stem(x,y,k));axis([0,7,-2,2]); subplot(2,2,4);fill(x,y,y); title(fill(x,y,y));axis([0,7,-2,2]); 第33页/共34页 第34页/共34页 * Instructor notes: Here we see our first example of fairly full featured 2D plot. In the slides that follow we will see how to go about arriving at a plot like this. The plot has a title that describes the dependent and independent variables. It has a label for the x-axis and for the y-axis. Each of these axis labels indicate what is being plotted with the corresponding units included in parentheses. The plot has major tick marks on each axis and the scale is such that an easily read step size occurs between each tick mark. Because there is more than one data set being plotted, there is a legend that indicates which curve corresponds to which data set. Note that the theoretical data is just a line, while the experimental data is a collection of data points that are connected by line segments. Data symbols should be used for measured data only, not for theoretical curves. Finally, there is a small text box that describes what is being plotted. 3.1 二维绘图 一、二维曲线的绘制 plot —— 最基本的二维图形指令 plot的功能: plot命令自动打开一个图形窗口Figure 用直线连接相邻两数据点来绘制图形 根据图形坐标大小自动缩扩坐标轴,将数据标尺及单位标注自动加到两个坐标轴上,可自定坐标轴,可把x, y 轴用对数坐标表示 第1页/共34页 plot的功能: 如果已经存在一个图形窗口,plot命令则清除当前图形,绘制新图形 可单窗口单曲线绘图;可单窗口多曲线绘图;可单窗口多曲线分图绘图;可多窗口绘图 可任意设定曲线颜色和线型 可给图形加坐标网线和图形加注功能 第2页/共34页 plot的调用格式 plot(x) —— 缺省自变量绘图格式,x为向量, 以x元素值为纵坐标,以相应元素下标为横坐标绘图 plot(x,y) —— 基本格式,以y(x)的函数关系作出直角坐标图,如果y为n×m的矩阵,则以x 为自变量,作出m条曲线 plot(x1,y1,x2,y2, …) —— 多条曲线绘图格式 第3页/共34页 plot的调用格式 plot(x,y,’s’) —— 选项格式,选项量字符串s设定曲线颜色和绘图方式,使用颜色字符串的前1~3个字母,如 yellow—yel

文档评论(0)

1亿VIP精品文档

相关文档