Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to undo close tab in Matlab's editor?

Tags:

matlab

Many web browsers allow to undo close tab:

enter image description here

Is it possible to undo close tab in Matlab's editor?

I use R2014a on Windows 7.

like image 396
Franck Dernoncourt Avatar asked Jan 10 '23 07:01

Franck Dernoncourt


1 Answers

It isn't officially supported in MATLAB, but with reference to Undocumented MATLAB, there is a workaround.

MATLAB stores its Desktop windows state in a file called MATLABDesktop.xml that is located in the user’s prefdir (preference directory) folder. You can echo where this is in MATLAB by simply typing in prefdir in the Command Prompt and pushing Enter or RETURN. As you are also using Windows, you can also do this to open up the folder within MATLAB:

winopen(prefdir);

This should open up a new Windows Explorer window that will directly bring you to the prefdir folder.

This file includes information about the position and state of every Desktop window. Since the editor files are considered Desktop documents, they are also included in this file. As such, when you close the editor, these documents are simply removed from the MATLABDesktop.xml file.

It turns out that MATLAB automatically stores a backup version of this file in another file called MATLABDesktop.xml.prev, in the same prefdir folder. I'm also using MATLAB R2014a in Windows 7 and I have double-checked to see if these files are also on my system and they are!

So before doing anything else, close MATLAB, delete the latest MATLABDesktop.xml file, replace it with a copy of the MATLABDesktop.xml.prev file, renaming it to MATLABDesktop.xml. After, restart MATLAB and the editor should reopen with your previous tabs.

like image 101
rayryeng Avatar answered Jan 17 '23 17:01

rayryeng