美文网首页
2019-02-15 Octave数据绘制

2019-02-15 Octave数据绘制

作者: 孟圆的笔记 | 来源:发表于2019-02-15 12:50 被阅读0次
>> t = [0 : 0.01 : 0.98];
>> y1 = sin(2*pi*4*t);
>> y2 = cos(2*pi*4*t);

>> plot(t,y1);
>> hold on;
>> plot(t,y2,'r');

>> xlabel('time');
>> ylabel('value');
>> legend('sin','cos');
>> title('my plot');

>> cd Octave_codes/
>> print -dpng 'myPlot.png'

 

 

 

>> close all    %关闭所有图片窗口
>> figure(1); plot(t,y1);    
>> figure(2); plot(t,y2);

 

 

 

>> subplot(1,2, 1);  %divide plot a 1X2 grid, access the first element
>> plot(t, y1);
>> axis([-0.5 1 -1 1]);
>> subplot(1,2, 2);  %divide plot a 1X2 grid, access the second element
>> plot(t, y2, 'r');
>> axis([-0.25 1  0 1]);

>> print -dpng 'subplot.png'

 

 

 

>> clf;    %清空图示窗口
>> A = magic(5)
A =

   17   24    1    8   15
   23    5    7   14   16
    4    6   13   20   22
   10   12   19   21    3
   11   18   25    2    9

>> imagesc(A), colorbar;    %矩阵的颜色分布图

>> print -dpng 'plotmatrix.png';

 

 

 

>> clf
>> imagesc(A), colorbar, colormap gray;    %灰度分布图

>> print -dpng 'graymapMatrix.png';

 

 

>> clf
>> imagesc(magic(15)), colorbar, colormap gray;   %逗号连接命令,是同时执行的意思

>> print -dpng 'largeGrayMatrix.png';

相关文章

网友评论

      本文标题:2019-02-15 Octave数据绘制

      本文链接:https://www.haomeiwen.com/subject/nkhpeqtx.html