Is there any way to resize the MATLAB IDE using MATLAB code? I want to be able to maximize the window or have it take up half the screen from a script. This is on a Windows machine.
I can probably call out to an external program like AutoHotkey to do it, but am wondering if there is a native way.
You can do this using a handle to the desktop:
desktop = com.mathworks.mde.desk.MLDesktop.getInstance;
desktop.getMainFrame.setSize(1200, 1000)
desktop.getMainFrame.setLocation(0, 0)
Related
I'm calling a script from another program (Vicon Nexus 2.3). This other program will launch Matlab, then run the script.
The first thing the script does is it calls uigetfile(). However since the Nexus program has the Windows focus, the uigetfile() window appears behind everything. Is there any way to bring it to the front without using the mouse?
I've tried:
shg
uistack()
But I think the issue here is windows focus, not uistack. Anyone out there know if this is possible?
What you need to do is bring Matlab to front before opening uigetfile dialogue. You can do that e.g. by calling commandwindow:
commandwindow();
uigetfile();
Tested by starting Matlab from command line and overlaying some other windows on top once it is open, but before the code after pause is executed:
matlab -r "pause(3); commandwindow(); uigetfile();"
I'm running a script on a PC (windows 7) with dual monitors, and every time when I open a new on-line window, Matlab freezes (not responding to mouse or keyboard inputs, only to calling windows task manager and switching tasks).
For what I've checked, only Screen('Openwindow') has this problem; other screen functions work fine. This failure never happens in single monitor situation.
Here's my script:
screeninfo.pos = get(0,'MonitorPositions');
if size(screeninfo.pos,1)<2
fprintf('cannot find two monitors! \n');
return;
end
[screeninfo.window, screeninfo.rect] = Screen('OpenWindow',0, [900 900 1000],screeninfo.pos(2,:));
Anyone has a clue?
Psychtoolbox 3.0.10 is ancient. You should update to the latest and greatest.
More importantly, when you open a window, any input (keyboard/mouse) goes to the opened screen, not matlab, unless you specifically focus matlab with alt-tab. cntr+C is an exception that makes matlab stop execution of the script, also when a PTB window is open.
If your matlab is on another screen than where the PTB window is opened, things should work normally. But if you start interacting with the matlab interface which a PTB window is open, all guarantees of proper timing of the PTB window are gone.
Is there any way to open MATLAB editor without opening MATLAB ? I would like to edit my codes using MATLAB editor and my laptop is getting very slow. So Can I just open MATLAB editor?
Also, is there any good editor like MATLAB's editor?
The MATLAB Editor is part of the IDE, so you can't launch it without launching MATLAB.
Notepad++ is a great text editor for Windows, that supports syntax highlighting for many languages, including MATLAB, and is pretty lightweight.
You can just open it in notepad or text editor. Just right click on it and select open with and then select whichever text editor you want to use.
Since MATLAB GUI is quite computationally expensive I open MATLAB without the GUI:
matlab -nodesktop
In such a way I have the MATLAB prompt ready to work and I edit files with sublime text editor setting MATLAB syntax.
It looks like this:
I am running a GUI in MATLAB. I want whenever my GUI gets opened MATLAB command window should be minimized?
I have tried with WindowAPI but it is not working. Please give some suggestions on how to do this.
You can do this using Matlab's Java support, thereby manipulating the (undocumented) Java objects that make up the Matlab IDE. As far as I know, the Command Window is always embedded in the main Matlab Desktop Window, so here's the code to minimize that.
Get a reference to the Java object that implements the Matlab Desktop:
desktop = com.mathworks.mde.desk.MLDesktop.getInstance();
Get a reference to the window (Java Frame) that contains the Desktop:
mf = desktop.getMainFrame();
Minimize it:
mf.setMinimized(true);
This approach works across platforms.
See http://undocumentedmatlab.com/ for more information on the undocumented internals of Matlab.
Is there a way to create a GUI which starts as a maximized windows?
I've tried to add set(gcf,'Units','normalized','Position',[0,0,1,1]); at the end of my gui's mygui_OpeningFcn() function but the GUI is not maximized properly (see printscreen).
Setting the GUI properties at GUIDE to Units-'normalized' and Position-[0,0,1,1] didn't help either.
I've also tried to use the Matlab File Exchange maximize function by adding maximize(handle.figure1); at the end of my gui's mygui_OpeningFcn() but it doesn't work either (same visual result - a GUI which is not entirely maximized).
Is there a way to make the Matlab GUI appear as a maximized figure when I launch it?
Why am I getting this strange visual behavior of the GUI?
If you are on a Windows machine, I suggest you use the WindowAPI submission from FEX. It directly calls Windows API functions (using a MEX file), thus allowing far more advanced control of figures than just minimize and maximize:
hFig = figure('Menubar','none');
WindowAPI(hFig,'Maximize')