Is there a way to change the name of the MATLAB command window?

I am using the C ++ API to run MATLAB (via engOpenSingleUse). Everything is working fine. But I would like to change the window title from "MATLAB Command Window" to something else.

I often have 4 or 5 of them open, and sometimes one of them becomes an orphan if my program crashes. If I could change the name, I would better understand which one was.

Is there a MATLAB command that I could execute (via engEvalString) to do this?

+4
source share
2 answers

For Matlab 7:

jDesktop = com.mathworks.mde.desk.MLDesktop.getInstance; jDesktop.getMainFrame.setTitle('my new title'); 

* or specifically for the command window:

 cmdWin = jDesktop.getClient('Command Window'); cmdWin.getTopLevelAncestor.setTitle('my new title'); 

For Matlab 6:

 jDesktop = com.mathworks.ide.desktop.MLDesktop.getMLDesktop; jDesktop.getMainFrame.setTitle('my new title'); 

* or for the command window:

 cmdWin = jDesktop.getClient('Command Window'); cmdWin.getTopLevelWindow.setTitle('my new title'); 


Other related undocumented desktop features are described here:
http://UndocumentedMatlab.com/blog/tag/desktop/

+10
source

Try coding directly against Java AWT classes. It can be more flexible and work inside the Matlab engine running under C ++. (I have not tested it in this context, since I do not use the engine.)

 function change_win_title(oldName, newName) wins = java.awt.Window.getOwnerlessWindows(); for i = 1:numel(wins) if isequal(char(wins(i).getTitle()), oldName) wins(i).setTitle(newName); end end 

You would use it like that.

 change_win_title('MATLAB Command Window', 'My new window name') 

You can use other tests (window class, etc.) to identify windows of interest.

+1
source

All Articles