No License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
maximize figure windows

4.4 | 35 ratings Rate this file 19 Downloads (last 30 days) File Size: 4.23 KB File ID: #10274 Version: 1.0

maximize figure windows


Alain Trostel (view profile)


08 Mar 2006 (Updated )

Maximize figure windows by using the Microsoft Windows application programming interface (API).

| Watch this File

File Information

Unzip the files and change the the "Current Directory" in MATLAB. Afterwards you can use the function "maximize.m". This function does the same as pressing the "maximize" button on the top right of the window. When you press the "maximize" button after using this function, the figure window will restore to its previous size.
The function is specific to Mircosoft Windows.


maximize the current figure

maximize the current figure

maximize the specified figure
h = figure;

maximize the application window

maximize more than one figure
h(1) = figure;
h(2) = figure;

maximize all figures

maximize a GUI in the OpeningFcn

% --- Executes just before untitled is made visible.
function untitled_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to untitled (see VARARGIN)

% Choose default command line output for untitled
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% maximize the GUI

MATLAB release MATLAB 6.5 (R13)
Other requirements Microsoft Windows
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (56)
30 Nov 2016 wlbcyy

wlbcyy (view profile)

In the under comments,Shio Williams' Work at 2010 is good!!!
Thx @Shio Williams

Comment only
04 Nov 2014 Alberto Lega

64 bit support needed.

13 Mar 2013 Christopher Beaudoin

64 bit support needed

25 Sep 2012 Roman Voronov

64 bit support needed

17 Jul 2012 Martin V.

Martin V. (view profile)

Thanks for very useful function.

29 May 2012 Shahar

Shahar (view profile)

Very useful!

I encounter a slight problem when using the function within a matlab GUI.
Adding "maximize(handles.figure1);" at the end of the mygui_OpeningFcn() function doesn't maximize the window as expected.

Did anyone encountered this problem before? How can I use the maximize function to enlarge the GUI at start?

29 May 2012 Shahar

Shahar (view profile)

25 Aug 2011 hailiang shen

Not sure since which matlab version the following will work, but with version R2011a, you may use a one line code:

set(gcf, 'Position', get(0,'ScreenSize'));

Comment only
16 Aug 2011 Atcold

Atcold (view profile)

Could be possible to have a version for 64 bit please? I don't have any compiler installed within Matlab..
Many thanks indeed

Comment only
01 Aug 2011 Atcold

Atcold (view profile)

And thanks also to Joseph! (:

21 Jul 2011 Joseph

Joseph (view profile)

To suppress the warning:
warning('off', 'MATLAB:mex:deprecatedExtension');

to supress it only temporarily
s = warning('off', 'MATLAB:mex:deprecatedExtension');


Comment only
02 May 2011 Joseph

Joseph (view profile)

Thanks, This is great, but like Andy was asking, is there a way to suppress the dll warning?

13 Apr 2011 vick Audi

27 Mar 2011 Nicolas

>> figure
>> hFig = gcf;
>> jFig = get(handle(hFig), 'JavaFrame');
>> jFig.setMaximized(true);

Comment only
21 Feb 2011 Michal Krejci

I have problem with maximizing GUI, when I put this:
% maximize the GUI
on the end of OpeningFcn everything seems fine and window is maximized, but then function gui_mainfcn ruined everithing with this code:

gui_hFigure = local_openfig(gui_State.gui_Name, 'reuse',gui_Visible);

(Matlab R2009a)
Any solutions?

Comment only
08 Feb 2011 Greg Elphick

I too find this fantastic, but am looking for a 64 bit version - any solutions here?

Comment only
13 Jan 2011 Andy

Andy (view profile)

whenever I run this, I get a warning about running MEX-files with .dll extensions. (I am running 2009b), just wondering if an update to get around this be possible?

Warning below:
"MEX-files with .dll extensions will not execute in a future version of MATLAB."

Comment only
29 Oct 2010 Nicholas

Does anyone have a copy of the c-file for 64 bit windows they could send me? I'd appreciate it.

Comment only
16 Jun 2010 zhou

zhou (view profile)

is here any linux version? thx

Comment only
14 Apr 2010 Shio Williams

here's a cool little work around. you need to know your figure window name, if you don't want to name it, you can simply name it temporarily using the set(hFig, 'Name', 'Figure X');

%Make it Full Screen

h = actxserver('WScript.Shell');
%Put the title of your window as seen in the title bar
h.AppActivate('Figure X');
h.SendKeys('% '); %this is shortcut key ALT + {SPACE}
h.SendKeys('{DOWN 4}');
h.SendKeys('~'); %This is enter

Comment only
12 Apr 2010 Niels K. H. Rasmussen

23 Feb 2010 Rashed

Rashed (view profile)

Thanks a lot.

28 Oct 2009 Martin Tettke

You need to compile the c-file for win64.
If anyone need a compiled version, drop me a note.

Comment only
30 Jun 2009 Alexander

As you can see from the post I sent 09/08 I was very happy with the application. I am now attempting to use the code in Windows 2003, 64bit edition and getting the same problem Jorg, Yasser and Alain had. Any suggestions other than using a different OS?


Comment only
27 Mar 2009 Jorg Entzinger

@Yasser, Alain Trostel

I have the same problem (I did have the .dll file in the same folder as my .m file, but ??? Undefined function or method 'windowMaximize' for input arguments of type 'char'. )

I think it may be because I'm using WinXP64 bit with Matlab 64bit version. Probably the dll is not compatible with that...

I hope someone will make a 64bit version available and post it here.

Comment only
04 Mar 2009 Yasser

Yasser (view profile)

John McArthur,

I did have the .dll file in the same folder as my .m file. Any idea why it wouldn't pick it up?

Comment only
04 Mar 2009 Johnny8088

I am really appreciated for this post. It works great.

07 Jan 2009 John McArthur

works perfect on R14, WindowsXP, with taskbar set to autohide. need to have the .dll file either in the folder with the .m file, or in your searchpath

31 Oct 2008 Yasser

Yasser (view profile)

I get this error:

??? Undefined function or method 'windowMaximize' for input arguments of type 'char'.

Error in ==> maximize at 149

Error in ==> Characterizing_Devices at 111

Why isn't it picking up the dll file?


Comment only
10 Sep 2008 Alex Orbell

Vey useful, does exactly what it says on the tin, make sure you download all three files though!

27 Aug 2008 ram ram

Great post.. It is useful

30 Jun 2008 Nick Steinmetz

So much better than the other hacks involving the 'Position' property of the window - those just make it fill the window (sometimes more or less completely) while this function literally does the same thing as clicking maximize yourself. Thanks, Alain!

14 Feb 2008 Miroslav Pajic


29 Nov 2007 Niels Scheffer

thanks a lot!
I was really annoyed by double clicking for maximizing and the get('Screensize') set-thing doesn't work for me (if it comes to beauty)

17 Nov 2007 Tim Scribner

Works as indicated

31 Jul 2007 Jeff Jackson

Works as expected. :-)

21 Jun 2007 François Mourougaya

Works nicely.

20 Jun 2007 chris lee

works perfectly on (R2007a)!

thanks Alain

12 Jun 2007 Khalid Aamir

It does not work at all.

26 Sep 2006 Matt Strasser

I can't thank you enough for this. By the way even though it says it was designed for R13, it works brilliantly in 2006a.

20 Sep 2006 Alain Trostel

I think there is no way to set the default factory settings, sorry.

Comment only
20 Sep 2006 Laurentiu B

nice stuff, is there a way to set the default factory settings to make all new figures maximized from the start?

16 Sep 2006 Jörg Buchholz

You saved my day! Thanks alot...

30 Aug 2006 Scott Miller

Seems to work pretty well, although when I fired it up for the first time and unlocked my taskbar, windows IE locked up and I had to kill it with the taskmanager. It hasn't done that since (nor have I tried unlocking the taskbar since).

Scott Miller

18 Aug 2006 Jaime Matas

Great! I've been looking for the way to maximize a figure in MATLAB a lot of time... and it's really possible!!

11 May 2006 David Scraggs

09 May 2006 cm jones

First time using code from this author. Really impressive. The code is absolutely "clean" and WELL documented.

Great job. (Would've taken me forever to write it.)

23 Apr 2006 Busa-Fekete Robert

06 Apr 2006 Stefan Eicher

Super sach. tschö

31 Mar 2006 Marcel Matthey-Doret

as usual the source code is well documented. i've been looking a long time for such a function and i was never able to develop it by myself. thanks a lot...

10 Mar 2006 Alain Trostel

The zipped folder is not updated yet, only the description. MathWorks will solve this problem.

Comment only
09 Mar 2006 Duane Hanselman

Note that a platform independent solution (using Java calls) already exists. See file #9523. I know that I always prefer a platform independent solution. I am not a Java person, so that is why I wrote "maxfigsize" as a poor man's alternative.

Comment only
09 Mar 2006 John D'Errico

If it has different functionality from an existing tool, then I'd recommend stating that in the description. I will note that this tool is of course specific to Windows. This should be listed in the requirements, as well as the statement in the summary line. So while maxfigsize [FEX 3036] works on any platform, maximize is platform specific. This is important for installations that support multiple platforms. A friendly touch would be to allow the user to just type "maximize" with no arguments, which would then be equivalent to maximize(gcf). While I can't test the functionality of this code as I use a different OS, the help seems quite reasonable.

09 Mar 2006 Alain Trostel

It's not the same like the function "maxfigsize.m" by Duane Hanselman. After you maximized the figure window with my function, you have the option to restore the figure window by push the middle button on the top right. When you use the function "maxfigsize.m" it doesn't work.

Comment only
09 Mar 2006 Stefan Gautschi


08 Mar 2006 F Moisy

Idem as maxfigsize by Duane Hanselman, isn't it?

Comment only
09 Mar 2006

You can use the function now without an input parameter

10 Mar 2006

zipped folder was not updated

20 Mar 2006

You can now maximize more than one figure, all figures or the application window

27 Mar 2006

improvement of the code metrics

11 Apr 2007

works also when the window is not resizable

Contact us