1. Graphics Window objects
The output of all graphical images of MATLAB is done in the graphics window.
First, create
The graphical window object is created using the figure function, whose invocation format is: Handle variable =figure (property name 1, property value 1, property name 2, property value 2, ...)
Matlab changes the form of the graphics window by manipulating property one. You can also use the figure function to create a graphics window with the MATLAB default property value, in the form of: Figuresor handle variables =figure
After MATLAB establishes a window through the figure function, you can also call the figure function to display the window and set it as the current window with the format: Figure(Window handle)
If the handle here is not a window handle that already exists, but an integer, you can also use this function, which is to generate a new graphics window for this handle and define it as the current window. If the referenced window handle is not a graphics window
Handle and is not an integer, the function returns an error message.
Close the graphics window, using the Close function, whose invocation format is: Close (Window handle)
In addition, theclose all command closes all graphics Windows , and theCLF command clears the contents of the current graphics window without closing the window.
Second, MATLAB provides a lot of properties for each graphics window. These properties and their values control the graphics window object. In addition to the public properties, other common properties are as follows. Unique Properties
(1) The MenuBar property. The value of this property can be either a figure (the default) or none. Used to control whether the graphics window should have a menu bar. If its property value is None, it indicates that the graphics window has no menu bar.
Users can use the Uimenu function to add their own menu bar, if the property value is figure, the window will remain the default menu bar of the graphic, you can also use the Uimenu function to add a new menu item after the original default graphics Window menu.
(2) The Name property. The value of this property can be any string, and its default value is null. This string is used as the caption for the graphics window. In general, its title is: Figure the most: string.
(3) The Numbertitle property. The value of this property is on (default) or off. Determines whether to prefix the caption with "Figure NO.N:" In the caption of the graphics window, where n is the ordinal of the graphics window, which is the handle value.
(4) The Resiza property. The value of this property is on or off. Determines whether the window can be resized with the mouse after the graphics window is created.
(5) The Position property. The value of this property is a four-element vector in the form of [X,y,w,h]. This vector defines the position and size of the graphics window object on the screen, where x, Y is the horizontal value of the lower-left corner of the window, and W and H are the width and height of the window, respectively.
Their units are determined by the Units property.
(6) The Units property. The value of this property can be any of these strings: pixel (pixels, default), normalized (relative units), inches (inches), centimeters (centimeters), and points (points).
(7) The Color property. The value of this property is a color value that can be expressed either as a character or as an RGB ternary. The default value is ' K ', which is black, which sets the background color of the graphics window.
(8) The Pointer property. The value of this property is an arrow (default), Crosshair, watch, TOPL, TOPR, Circle, Cross, Fleur,custom, and so on, to set the display of the mouse marker.
(9) for keyboard and mouse response properties. MATLAB allows you to respond to actions such as pressing keyboard keys and mouse keys, such as KEYPRESSFCN (keyboard key press response), WINDOWBUTTONDOWNFCN (left mouse button pressed response), WINDOWBUTTONMOTIONFCN ( Mouse movement Response) and WINDOWBUTTONUPFCN (mouse button release response), these properties corresponding to the property value can be written in MATLAB function name or command name, once the keyboard key or mouse button pressed,
The given function or command will be called automatically.
Example: Create a graphics window, no menu bar, title name "Graphics Window Example", starting at the bottom left corner of the screen, width and height of 300 pixels and 150 pixels, the background color is green,
And when the user presses any key from the keyboard, the word "Hello,keyboard Key Pressed" is displayed.
The command is as follows:
>> hf=figure (' Color ', [0,1,0], ' Position ', [1,1],300,150,... ' Name ', ' graphics window example ',)
Creation of graphical objects (methods of creating common graphical objects and special properties)