操作方法
绘制图像前首先需要得到曲线数据,如下所示即为计算过程: % calculate the first line x1 = 0:0.01:10; y1 = x1.^2; % calculate the second line x2 = 0:0.01:10; y2 = x2; plot(x2,y2);
在绘制曲线时常用plot(x,y)函数,如下所示: plot(x1,y1); plot(x2,y2); 为了保证绘制在同一幅图中,所以需要使用命令: hold on
设置图像的横坐标轴和纵坐标轴,并设置标题: xlabel('x') ylabel('y') title('在一幅图中绘制多条曲线') 综上所述,完整的代码如下所示,点击红色箭头所指的运行按钮就可以看到运行结果:
运行结果如下所示: