In App Designer and apps created with the uifigure function, uiconfirm is recommended over questdlg because it provides additional customization options. By default, the dialog box has three standard buttons, labeled Yes , No , and Cancel. If the user clicks one of these buttons, then the answer value is the same as the label of the pressed button.
If the user clicks the close button X on the dialog box title bar or presses the Esc key, then the answer value is an empty character vector ' '. If the user presses the Return key, then the answer value is the same as the label of the default button selection. In this case, 'Yes'. The defbtn value must match one of the button labels. The third standard button is removed. The defbtn value must match the value of btn1 or btn2. If the user presses the keyboard Return key, and the defbtn value does not match one of the button labels, then the dialog box remains open.
Create a question dialog box with three custom buttons. Assign a different value to the dessert variable depending on the button the user clicks. To access the return value assigned to dessert , save the example as a function.
For example, create function choosedessert by making this the first line of code. Dialog box question, specified as a character vector, cell array of character vectors, or string array. The question automatically wraps to fit within the dialog box. Example: 'What is the velocity?
Example: 'Configuration'. The default button selection, specified as a character vector or string scalar. The default selection must be the same as one of the dialog box button labels. If the defbtn argument value does not match a button label, then the dialog box remains open if the user presses the keyboard Enter key. Search Support Clear Filters. Support Answers MathWorks. Search MathWorks. MathWorks Answers Support. Close Mobile Search.
Trial software. You are now following this question You will see updates in your followed content feed. You may receive emails, depending on your communication preferences. Why can't I change my WindowStyle setting? Show older comments.
Sebastian Sigler on 13 Jul Vote 1. Answered: Sudhanshu Bhatt on 19 Jul I would like to change some figure properties before printing them, like the color, units and position:. The execution of that command works just fine and I get a normal figure with the changes I wanted but when I try to run the file with the Report Generator none of the changes are applied to my figure.
Removes all axes objects and resets figure properties to their defaults before adding new graphics objects. Equivalent to using the clf reset command. Consider using the newplot function to handle the NextPlot property. The OpenGL renderer displays objects sorted in front to back order, as seen on the monitor.
Lines always draw in front of faces when at the same location on the plane of the monitor. This option works well for axes in a 2-D view. In 2-D, the Painters renderer sorts graphics objects by child order order specified.
In 3-D, the Painters renderer sorts objects in front to back order. However, it might not correctly draw intersecting polygons in 3-D. The 'zbuffer' option has been removed. Use 'opengl' or 'painters' instead.
However, if you have graphics hardware that supports a hardware-accelerated version of OpenGL, then MATLAB automatically uses the hardware-accelerated version to increase performance. For example, MATLAB uses the software version if it detects graphics hardware with known driver issues or detects that you are using a virtual machine or remote desktop on Windows.
On Windows, OpenGL is available as part of the operating system. If you experience problems with OpenGL, contact your graphics driver vendor to obtain the latest qualified version of OpenGL.
For example, this command gets the information for the current axes and stores it in a structure called info. This structure also provides the name of the graphics renderer in the GraphicsRenderer field. If this happens, ensure that the system has the latest XServer installed.
Axes graphics smoothing, specified as 'on' or 'off' , or as numeric or logical 1 true or 0 false. Smoothing reduces the appearance of jagged lines in an axes graphic. MATLAB applies a smoothing technique to an axes graphic and the axes rulers if GraphicsSmoothing is set to 'on' , and either of these conditions is true:.
The Renderer property is set to 'painters'. The Renderer property is set to 'opengl' and your hardware card supports OpenGL. If your axes graphic contains mostly vertical or horizontal lines, consider setting the GraphicsSmoothing property to 'on' and the line or lines AlignVertexCenters property to 'on'. The smoothing technique sacrifices some sharpness for smoothness, which might be particularly noticeable in such graphics.
Graphics smoothing has no affect on text. Figure size and location on page when printing or saving, specified as a four-element vector of the form [left bottom width height]. If the width and height values are too large, then the figure might not reach the specified size. If the figure does not reach the specific size, then any UI components on the figure, such as a UI control or a UI table, might not save or print as expected.
The PaperUnits property determines the units of measurement of the PaperPosition values. Consider setting the PaperUnits property to 'normalized'. This setting enables MATLAB to automatically size the figure to occupy the same relative amount of the printed page, regardless of the page size.
Example: figure 'PaperPosition',[. Directive to use displayed figure size when printing or saving, specified as either 'auto' or 'manual'. The width and height values of the PaperPosition property equal the figure size on the display. The left and bottom values center the figure.
If the figure size changes on the display, the PaperPosition property automatically updates to the appropriate size and location values. Use this option if you want to print or save the figure using a size that differs from the display, or if you do not want the figure centered on the printed or saved page.
Set the PaperPosition property to the desired size and location. If the figure size changes on the display, the PaperPosition property does not automatically update. To generate output that has the same size and resolution DPI as the displayed figure, set the PaperPositionMode property of the figure to 'auto' and save the figure using print with the -r0 option.
The -r0 option ensures that the output resolution is the same as the display resolution. If the resolutions are different, then the generated output size matches the displayed figure size in measured units inches, centimeters, points , but not in pixels. For example, if the display resolution is DPI, then a 4-by-5 inch figure is by pixels.
If the output resolution is DPI, then the printed or saved figure is the same size in inches, but by pixels. Starting in Ra, the default value is 'auto'. Previously, the default value was 'manual'. Set a print preference. You can set the print preference to either 'auto' or 'manual' , for example: matlab.
If you set a preference, the command returns 'auto' or 'manual'. If you did not set a preference, the command returns 'unset'. Set the default value on the root object. In the United States, the default value is [8. In Europe and Asia, the default value is [21 Other file formats ignore this property. Use the PaperPosition property to control the size of the saved figure. The PaperUnits property determines the units of measurement for the PaperSize property. You cannot set the PaperSize property if the PaperUnits property is set to 'normalized'.
Attempting to do so results in an error. Specifying the PaperSize property sets the PaperType property to the corresponding type, if one exists, or to 'custom' otherwise. Units used for PaperSize and PaperPosition , specified as one of these values:. This is the default when the locale is the United States. The lower left corner of the page maps to 0,0 and the upper right corner maps to 1,1.
This is the default when the locale is Europe or Asia. If you change the value of the PaperUnits property, it is good practice to return the property to its original value after completing your computation so as not to affect other functions that assume the PaperUnits property has not changed. Orientation of page when printing figure or saving it to a paged format PDF and PostScript formats , specified as one of these values:.
See the orient function for more information. Other formats ignore these values. Standard page sizes when printing the figure or saving it to a paged format PDF and PostScript formats , specified as one of the values in this table. Specifying the PaperType property sets the PaperSize property to the corresponding page size. Custom page size. Specifying a non-standard page size using the PaperSize property sets PaperPosition to this value.
Figure background color when saving or printing, specified as 'on' or 'off' , or as numeric or logical 1 true or 0 false.
Text and other aspects of the figure also might change color to improve the appearance of the generated output. To change the figure background color on the display, use the Color property of the figure. To change the axes background color, use the Color property of the axes.
Pointer symbol, specified as one of the values in the following table or as 'custom'. The appearance of the symbol is operating-system dependent. To create a custom pointer symbol, programmatically set the Pointer property to 'custom' and use the PointerShapeCData property to define the symbol.
See the PointerShapeCData property for more information. Custom pointer symbol, specified as a by matrix for a by pixel pointer , or as a by matrix for a by pixel pointer. The figure uses this pointer symbol when you set the Pointer property to 'custom'. Each element in the matrix defines the brightness level for 1 pixel in the pointer, where the element can have one of these values:.
NaN — Transparent pixel, such that underlying screen shows through. Element 1,1 of the matrix corresponds to the pixel in the upper left corner in the pointer. Active pixel of the pointer, specified as a two-element vector. The vector contains the row and column indices of a particular element in the PointerShapeCData matrix that corresponds to the desired active pixel.
The default value of [1 1] corresponds to the pixel in the upper left corner of the pointer. If you specify a value outside the range of the PointerShapeCData matrix, then the pointer uses the default active pixel of [1 1] instead.
This property applies only when the Pointer property is set to 'custom'. State of visibility, specified as 'on' or 'off' , or as numeric or logical 1 true or 0 false. You still can access the properties of an invisible UI component. To make your app start faster, set the Visible property to 'off' for all components that do not need to appear at startup.
Changing the size of an invisible container triggers the SizeChangedFcn callback when it becomes visible. Changing the Visible property of a container does not change the values of the Visible properties of child components. This is true even though hiding the container causes the child components to be hidden.
Target axes in the current figure, specified as an Axes object, a PolarAxes object, or a graphics object such as a HeatmapChart.
In all figures for which axes children exist, there is always a current axes. The current axes does not have to be the topmost axes, and setting an axes to be the current axes does not restack it above all other axes. If a figure contains no axes, the get gcf,'CurrentAxes' command returns an empty array. Query the CurrentAxes property to get the current axes object without forcing the creation of an axes if one does not exist. Current object, returned as a child object of the figure.
This object is the front-most object in the view. The HitTest property of the child object controls whether that object can become the CurrentObject. Clicking an object whose HandleVisibility property is 'off' sets the CurrentObject property to an empty GraphicsPlaceholder array.
To avoid returning the empty array when users click a hidden object, set HitTest property of the hidden object to 'off'. Use the gco command as an alternative for getting the value of this property.
Current point, returned as a two-element vector. The vector contains the x , y coordinates of the mouse pointer, measured from the lower-left corner of the figure. The values are in units specified by the Units property.
Press the mouse button within the figure, and then release it outside the figure. Move the mouse within the figure without pressing any buttons , provided that the WindowButtonMotionFcn property is not empty. If the figure has a callback that responds to mouse interactions, and you trigger that callback faster than the system can execute the code, the coordinates might not reflect the actual location of the pointer.
Instead, they are the location when the callback began execution. If you use the CurrentPoint property to plot points, the coordinate values might contain rounding error. Current character, returned as the character of the last key pressed. This property updates when the figure has focus while the user presses a key. The behavior of the Selected property changed in Rb, and it is not recommended.
It no longer has any effect on objects of this type. This property might be removed in a future release. Use of the SelectionHighlight property is not recommended. This property has no effect on figures. Mouse selection type, returned as 'normal' , 'extend' , 'alt' , or 'open'.
This property provides information about the last mouse button press that occurred in the figure. This table lists the possible SelectionType values and the user actions that produce those values. Control -click the left mouse button. Context menu, specified as a ContextMenu object created using the uicontextmenu function. Use this property to display a context menu when you right-click on a component.
A cell array in which the first element is a function handle. Subsequent elements in the cell array are the arguments to pass to the callback function. For more information about specifying a callback property value as a function handle, cell array, or character vector, see Specify a Callback Function. Use the SelectionType property to determine whether the user pressed modifier keys.
Use the gcbo function in your CreateFcn code to get the component object that is being created. Setting the CreateFcn property on an existing component object has no effect.
Use the gcbo function in your DeleteFcn code to get the component object that is being deleted. This callback function executes when the user presses a key while the figure or a child object has focus.
If the user presses a key on a UIControl or Table component, the callback does not execute unless the Enable property is set to 'off' or 'inactive'. This table lists the properties of this object. The character that appears as a result of pressing the key or keys. Pressing certain keys or modifying keys with the Ctrl key might put unprintable characters in the Character property.
Pressing certain keys alone such as Ctrl , Alt , Shift does not generate Character data. Cell array containing the names of the modifier keys pressed, such as control , alt , or shift. If no modifier keys are pressed, the cell array is empty.
The key pressed, identified by the lowercase label on the key, or a descriptive word such as 'space'. For more information about specifying callback property values and using callback arguments, see Specify a Callback Function. The CurrentCharacter property also returns character information. If the user releases a key on a UIControl or Table component, the callback does not execute unless the Enable property is set to 'off' or 'inactive'.
Character that corresponds to the key or keys that are released. Certain keys or key combinations might return unprintable characters in this property.
Pressing and releasing certain keys alone such as Ctrl , Alt , Shift does not generate Character data. Cell array containing the names of the modifier keys released, such as control , alt , or shift. If no modifier keys are released, the cell array is empty.
Key released, identified by the lowercase label on the key, or a descriptive word such as 'space'. This callback executes whenever a user attempts to close a figure window. You can, for example, display a dialog box to ask a user to confirm or cancel the close operation or to prevent users from closing a figure that contains a UI.
A user issues the close or close all command from the command line, closes the figure from the computer window manager menu, or closes the figure by quitting MATLAB. The close operation executes the function defined by the figure CloseRequestFcn property.
The default value is 'closereq'. The 'closereq' operation unconditionally deletes the figure, destroying the window. You can call delete f from the command line if you have created a window with a nondestructive close request function. This example shows how to code the close request function to display a question dialog box asking the user to confirm the close operation. Save the code to a writable folder on your system. Notice that the function handle does not explicitly refer to any input arguments, but the function declaration includes two input arguments.
The first argument is the UI component that triggered the callback, and the second argument provides event data to the callback function. Define this callback to customize the app layout when the size of this container changes e.
This container becomes visible for the first time after its size changes. This situation occurs when the size changes while the container is invisible, and then it becomes visible later.
Other important points to consider when defining a SizeChangedFcn callback:. Consider delaying the display of this container until after all the variables that the SizeChangedFcn uses are defined. This practice can prevent the SizeChangedFcn callback from returning an error. To delay the display of the container, set its Visible property to 'off'. Then, set the Visible property to 'on' after you define the variables that your SizeChangedFcn callback uses.
If your app contains nested containers, they resize from the inside out. To access the container that is resizing from within the SizeChangedFcn , refer to the source object the first input argument in the callback or use the gcbo function. As an easy alternative to specifying a SizeChangedFcn callback, you can set the Units property of all the objects you put inside a container to 'normalized'.
0コメント