zoukankan      html  css  js  c++  java
  • octave基本指令4

    octave基本指令4

    图形化显示数据

    >> t=[0:0.01:0.98];
    >> y1 = sin(2*pi*4*t); %pi表示π
    
    >> plot(t,y1);
    >> y2 = cos(2*pi*4*t)
    
    >> plot(t, y1);
    >> hold on;  %将新的图像直接绘制在旧的图像上,
    >> plot(t, y2, 'r'); %'r'代表图像的颜色
    
    >> xlabel('time') %标记X轴为time
    >> ylabel('value') %标记y轴为value
    
    >> legend('y1','y2') %将图像的图例标识在右上角
    >> title('xxx') 将图像名称标记在上方
    
    >> print -dpng 'myPlot.png' %将图像保存为png格式
    >> close %关掉图像
    
    >> figure(1);plot(t,y1);%同时显示多张图片的方式,这是图1
    >> figure(2);plot(t,y2);%这是图2
    
    >> subplot(1,2,1); %将图像分为一个1*2的格子,使用第一个格子
    >> plot(t,y1);
    >> subplot(1,2,2); %将图像分为一个1*2的格子,使用第二个格子
    >> plot(t,y2);
    >> axis([0.5 1 -1 1]) %设置x轴坐标为0.5到1之间,y轴坐标为-1到1之间
    
    >> clf; %清除一幅图像 
    
    矩阵的可视化
    >> A = magic(5);
    >> imagesc(A)  %绘制一个5*5的矩阵 一个5*5的彩色格图 不同的颜色对应 A矩阵中的不同值 
    >> colorbar, %在右边加入一个颜色条
    >> colormap gray; %生成了一个灰度分布图
  • 相关阅读:
    wget(转)
    852. Peak Index in a Mountain Array
    617. Merge Two Binary Trees
    814. Binary Tree Pruning
    657. Judge Route Circle
    861. Score After Flipping Matrix
    832. Flipping an Image
    461. Hamming Distance
    654. Maximum Binary Tree
    804. Unique Morse Code Words
  • 原文地址:https://www.cnblogs.com/passbyone/p/6366439.html
Copyright © 2011-2022 走看看