zoukankan      html  css  js  c++  java
  • Matlab学习笔记 figure函数

    Matlab学习笔记 figure函数


    matlab中的 figure 命令,能够创建一个用来显示图形输出的一个窗口对象。每一个这样的窗口都有一些属性,例如窗口的尺寸、位置,等等。下面一一介绍它们。

    一、概述 

     总的来说,figure 的使用语法包括:

      figure

     figure('PropertyName',propertyvalue,...)

     figure(h)

     h = figure(...)

     第一种用法最简单,它创建一个窗口,其各种属性都是使用默认设置。例如它创建的窗口立即成为当前窗口,并显示在其它窗口之上。直到新的窗口被创建或者其它窗口被唤醒(called)。

     第二种用法,figure('PropertyName',propertyvalue,...),则可以指定某些属性。例如“Name”属性,则可以指定该窗口的标题:

     figure('Name','显示处理结果');

                 

     “Position”属性则指定窗口的大小和位置:

     figure('Position',[600, 300, 300, 200]);

     其中属性值为一个四元数组 rect = [left, bottom, width, height],第一、二个参数表示窗口位置,都是从屏幕的左下角计算的。

     第三种用法,figure(h),则根据参数 h 的不同而表现不同。如果 h 是先前一个窗口的句柄(handle),则figure(h)相当于唤醒了该窗口,使得该窗口为当前窗口;如果 h 并不是某个窗口的句柄,但它是一个整数,则 figure(h)
    创建一个句柄为 h 的新窗口。

     最后一种用法,h
    = figure(...),相当于前面三种用法中在创建一个窗口的同时,返回该窗口的句柄。

    二、用法举例 

    1、在同一个figure中显示多个contour,可通过“hold on” 来实现:

      a = ones(500,500);

      figure('name','叠加显示图像');

     

      b = a;

      b(10:500-10,10:500-10) = 0;

      contour(b,[0 0],'r');
      hold on;

     

      c = a;

      c(100:400,100:400) = 0;   

      contour(c,[0 0],'b');

      hold off;

                                               

    2、figure 默认的坐标原点在左下角,这会导致有些图形图像的显示出现上下翻转,这时可通过:set(gca,'ydir','reverse','xaxislocation','top'); % 将坐标原点设在左上角

    3、指定坐标轴显示的坐标范围:xlim([xmin xmax])

     

    转自:http://blog.sciencenet.cn/blog-936367-714978.html

  • 相关阅读:
    poj 1579(动态规划初探之记忆化搜索)
    hdu 1133(卡特兰数变形)
    CodeForces 625A Guest From the Past
    CodeForces 625D Finals in arithmetic
    CDOJ 1268 Open the lightings
    HDU 4008 Parent and son
    HDU 4044 GeoDefense
    HDU 4169 UVALive 5741 Wealthy Family
    HDU 3452 Bonsai
    HDU 3586 Information Disturbing
  • 原文地址:https://www.cnblogs.com/sddai/p/5399463.html
Copyright © 2011-2022 走看看