12.07.2015 Views

MATLAB Function Reference (Volume 2: Graphics)

MATLAB Function Reference (Volume 2: Graphics)

MATLAB Function Reference (Volume 2: Graphics)

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Figure PropertiesThis close request function never closes the figure window; it simply echoes“This window is immortal” on the command line. Unless the close requestfunction calls delete, <strong>MATLAB</strong> never closes the figure. (Note that you canalways call delete(figure_handle) from the command line if you havecreated a window with a nondestructive close request function.)A more useful application of the close request function is to display a questiondialog box asking the user to confirm the close operation. The following M-fileillustrates how to do this.% my_closereq% User-defined close request function% to display a question dialog boxselection = questdlg('Close Specified Figure?',...'Close Request <strong>Function</strong>',...'Yes','No','Yes');switch selection,case 'Yes',delete(gcf)case 'No'returnendNow assign this M-file to the CloseRequestFcn of a figure:set(figure_handle,'CloseRequestFcn','my_closereq')To make this M-file your default close request function, set a default value onthe root level.set(0,'DefaultFigureCloseRequestFcn','my_closereq')<strong>MATLAB</strong> then uses this setting for the CloseRequestFcn of all subsequentlycreated figures.ColorColorSpecBackground color. This property controls the figure window background color.You can specify a color using a three-element vector of RGB values or one of<strong>MATLAB</strong>’s predefined names. See ColorSpec for more information.2-169

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!