Closing Time at the Document Bar
When you are done working with a “document” (M-File in the Editor, variable in the Array Editor, docked Figure, etc.) MATLAB offers a plethora of ways to close it:
- You can select File->Close my document from the menu
- You can press Ctrl-W (while the document has focus)
- You can click the X to the upper right of the document
- You can click the X on the document bar button (tab) corresponding to the document
- You can even right click on the document bar button and select Close my document from the context menu.
What more could you want?
Well if the document you are closing is an M-File with unsaved changes; you probably want MATLAB to prompt you regarding the disposition of the changes. Indeed, MATLAB will do so in response to any of the above close gestures. If you happen to know that you want to discard your changes you can avoid the prompting dialog by holding down the Ctrl key while pressing either of the X’s. MATLAB will respond by closing the document and discarding any changes without prompting you. This Ctrl key trick extends to closing the Editor itself. If you hold down the Ctrl key and press the X on the Editor’s title bar, the Editor will close, discarding unsaved changes to all files.
Sometimes, instead of closing a particular document you might want to keep a particular document open and close all the others. As of R2006b, the document bar button context menu offers a “Close all except my document” item for just this eventuality. This can be handy but it can also be frustrating when you instead want to keep a few documents open rather than just one. Here’s this menu item offering to do almost, but not quite, what you want. The solution is to use the “Close…” item that also appears on the context menu as well as on the File menu. This item has been present since R2006b. Close… opens a dialog that lets you choose which files to close.
In order to use this dialog to close all but a few documents, click the “Select All” button, then within the list at the left individually deselect the documents you want to keep open. Click the “Close Selected” button and MATLAB will do your bidding.
コメントを残すには、ここ をクリックして MathWorks アカウントにサインインするか新しい MathWorks アカウントを作成します。