欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

matlab 和octave笔画之如何画图表 plot()函数的简单介绍

程序员文章站 2022-05-13 12:45:45
画图命令plot(x,y)例子:>> t = [0:0.2:15];>> y = sin(pi*t);>> plot(t,y)>>图片在图表上再画一条线>> hold on;>> y2 = cos(pi*t)>> plot(t, y2, 'r') %'r' rea line添加xy轴标签, 标题和每天线的解释(legend)>> xlabel('time')>&....
  • 画图命令plot(x,y)
    例子:
>> t = [0:0.2:15];
>> y = sin(pi*t);
>> plot(t,y)
>>

图片
matlab 和octave笔画之如何画图表 plot()函数的简单介绍

  • 在图表上再画一条线
>> hold on;
>> y2 = cos(pi*t)
>> plot(t, y2, 'r') %'r' rea line

  • 添加xy轴标签, 标题和每天线的解释(legend)
>> xlabel('time')
>> ylabel('speed')
>> title('graph')
>> legend('sin','cos')

最终图片
matlab 和octave笔画之如何画图表 plot()函数的简单介绍

  • 存储图表
  • cd 'path'; print -dpng ;myPlot.png
  • 关闭窗口
  • close
  • 创建一个窗口并再上面画两个图
figure(1)
subplot(1,2,1) % 把一个窗口分成两个表,使用第一个表
plot(t, y1)
subplot(1,2,2) %使用第二个表
axis[0 1 -1 1] %标记x和y的范围

本文地址:https://blog.csdn.net/wchasedream/article/details/107489330