MATLAB Answers

How do I make a figure full screen programmatically in MATLAB?

6.262 views (last 30 days)
I would like to make my figure "full screen" without using the mouse to maximize the figure window.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 18 Oct 2013
To make a figure the same size as your screen in MATLAB execute the following command:
figure('units','normalized','outerposition',[0 0 1 1])
Please also see the related solution below for a method of programmatically maximizing, minimizing, and restoring a figure window.


Show 1 older comment
MathWorks Support Team
MathWorks Support Team on 4 Nov 2020 at 16:10
Starting in MATLAB R2018a, you can use the "WindowState" property to maximize, minimize, or display a figure in full-screen mode. Please refer to the following documentation for more information:

Sign in to comment.

More Answers (7)

Antonio Javier Barragán Piña
set(gcf, 'Position', get(0, 'Screensize'));


Show 2 older comments
Chuck on 18 Oct 2017
This one is actually way better than the one verified above. Great job, thanks!
Walter Roberson
Walter Roberson on 16 Jan 2020
You would put it in the code at the point at which you want to force the figure to full screen.
If you want to do it for a GUIDE GUI then you can put it in the *OpenFcn callback code.

Sign in to comment.

Bogdan Dzyubak
Bogdan Dzyubak on 16 Aug 2016
Edited: Bogdan Dzyubak on 16 Aug 2016
The proposed methods are simple but make the figure "nearly" full screen which can cause you to close the maximized Matlab session instead of the figure.
For actual maximize you can use the following:
frame_h = get(handle(gcf),'JavaFrame');


Show 6 older comments
John McDowell
John McDowell on 17 Oct 2020
As @Walter Roberson notes, JavaFrame will be removed in future releases. Inspired by @Bogdan's and @Antonio's answers, I went with:
Insert this after a figure has been created, and it will maxmise, but will keep the taskbar in view. Can also be run in the command window to make the last figure interacted with maximised.
Rik on 17 Oct 2020
You can use some code that checks what solution is supported by the release. That way you can ensure the function keeps working for releases that only support one or the other. Like this.
gaoyi guo
gaoyi guo on 23 Oct 2020
This may be the best solution, the figure window is maximized to the real screen size!

Sign in to comment.

Dominik Mattioli
Dominik Mattioli on 20 Jun 2019
Edited: Dominik Mattioli on 20 Jun 2019
If you want to account for the taskbar (I found this in the comments of some other question):
fh = figure();
fh.WindowState = 'maximized';


Show 4 older comments
Dominik Mattioli
Dominik Mattioli on 16 Jan 2020
Not sure what you mean without seeing any code. As long as you’re not reassigning the variable for the specific figure’s handle (fh) in your for loop, this solution should always work.
Steven Lord
Steven Lord on 16 Jan 2020
If you're creating many figure objects in a loop and want them all to be maximized, you could set that property at creation.
fh = figure('WindowState', 'maximized')
Most if not all settable properties of Handle Graphics objects can be set this way, though sometimes (mainly for properties that interact like Units and Position) you may need to be careful about your input argument ordering.

Sign in to comment.

Steven Lord
Steven Lord on 26 Apr 2018
It is possible to do this as of release R2018a using the WindowState property of a figure object.


Sign in to comment.

Jan on 26 Feb 2018
Under Windows you can use the API of the OS, see :
FigH = figure;
WindowAPI(FigH, 'full'); % fill the current monitor
WindowAPI(FigH, 'work'); % fill the current monitor without taskbar, if there is one
No window border anymore, just the inner position.


Sign in to comment.

WCJHunter on 27 Jan 2019
As steven lord above said:


Sign in to comment.

Martin Leo
Martin Leo on 21 Mar 2019
Edited: Martin Leo on 21 Mar 2019
To open a fullscreen figure window in MATLAB, use the "Position" option of the figure command. There are two way:
  1. Get the screen size and give it to figure:
s = get(0, 'ScreenSize');
figure('Position', [0 0 s(3) s(4)]);
2. Without bothering to get the screen size, use normalized units:
figure('Units','normalized','Position',[0 0 1 1])

  1 Comment

Walter Roberson
Walter Roberson on 21 Mar 2019
This will give you "full screen except for the title bar or dock or bottom bar". You need other techniques for true full screen.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by