File Exchange

image thumbnail

Maximize window

version (1.59 KB) by Yuval Cohen
Maximize window size to fill the entire screen. Has learning capability.


Updated 22 Mar 2005

No License

Maximize the size of figures and GUIs to fill the entire screen.

The function was tested under the following conditions:
screen resolutions:
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.

Cite As

Yuval Cohen (2020). Maximize window (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (27)


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?

joo tan

i try use this program..but failed..what the value for (h)? still 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.

James Huber

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:

Serge Thill

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)]);

Junior JR


Wenying Shou


Emma Peeling

This is excellent... just what I need and works exactly as described

yaniv the magnificent

Tevorah :)
It was great...

thanks a lot.
Yaniv and Amit.

Kiran Misra

Awesome .. saved my butt.

Julie Meng


Florian Weichert

Really useful.

Kjetil Sæheim


Kai-Cheng Hu

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.

Alfredo Fernandez

David Babineau

Excellent! Very easy to use and handy.

Tim Myers

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.

Ugo Di Girolamo

does not handle my office toolbar, though

Muni Gangabathina

Cool. This is exactly what I wanted!

Jim Bean

Marc Franco

Works great. Good job!

Aaron Luttman

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.

Brahim Hamadicharef

Thanks for this !
I do often prefer FULL SCREEN !


Kousuke Miyahara

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.
Well done


New feature - resize image to fill a portion of the screen

Updated calibration process.

MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: subfig, Simulation of Random Walk