Maximize the size of figures and GUIs to fill the entire screen.
The function was tested under the following conditions:
Matlab version: R12, R13
The function was calibrated to handle WinXP standard toolbar (at the bottom of the screen, one icon row) and standard screen (4x3 ratio - not wide).
If you are using different settings, the maximized figure size could be wrong. If you find yourself in such a position, fear not. Run the function in 'calibrate' mode to calibrate the settings.
The application will ask you to maximize a figure window manually and use these settings as a reference from now on.
2005-03-21 update - contribution of Tim Myers
Maximize can set the image to fill any portion of the screen.
Yuval Cohen (2020). Maximize window (https://www.mathworks.com/matlabcentral/fileexchange/3812-maximize-window), MATLAB Central File Exchange. Retrieved .
this function works for me, but I got a little problem. When I click to resize the window to the my figure old size nothing happens. What should I try?
i try use this program..but failed..what the value for (h)? still confuse..help me
You can also add
elseif screen(3) == 1680
set(gcf,'Units','normalized','Position',[0.00 0.0267 1.0 0.9095])
works for me !
Well done! Works just as a maximized window does, without the window being "maximized" in Windows terms.
Also, try it this way:
maxWindow=[1 31 scrsz(3) scrsz(4)-104];
%31 happens to be the pixel width of the task bar and 73 was the space required for the figure toolbar (73+31=104)
%choose any number that is available
%maxWindow is in the form [distance-from-left distance-from-bottom window-width window-height]
Also, you can find your maximized position this way:
%manually maximize the window with the mouse here
You can deterimine the default window size this way:
Just for information, if the purpose is simply to maximse a window, these two lines (slightly modified from the Matlab help) should also do the job:
scrsz = get(0, 'ScreenSize');
figure('Position', [1 scrsz(4) scrsz(3) scrsz(4)]);
This is excellent... just what I need and works exactly as described
It was great...
thanks a lot.
Yaniv and Amit.
Awesome .. saved my butt.
Thank you so much. It works properly on my PC . And I also learned some skills form your code(ex:an undocumented fig property-- ActivePositionProperty d). That is so perfect than I wrote.
Excellent! Very easy to use and handy.
I tried a few different functions all claiming to do the same thing. This function is the only one that worked properly on all screen resolutions. Hopefully, Matlab will include this type of function in a near-term release.
does not handle my office toolbar, though
Cool. This is exactly what I wanted!
Works great. Good job!
This is exactly what I have needed for opening and closing a lot of different plot windows, since I always want them maximized. This is a nice easy way to do it, and it works exactly as it says.
Thanks for this !
I do often prefer FULL SCREEN !
Works as advertized. The only file I found here that makes the figure fill the entire screen. Even thought the figure is not "Maximized", the size and position are exactly the same.
New feature - resize image to fill a portion of the screen
Updated calibration process.