MATLAB Answers

How to make figure window change size

4,974 views (last 30 days)
The figure window stopped responding to commands. The figure window size does not change when I try to resize it using set(gcf, [ four values]) which I have been using for sometime now. I have entered all the usual commands I normally use (from the command window) but it has no effects. It seems the window size is fixed so I need to make flexible. This started a day ago. How can I make it work again?
I use R2016a.
Thanks in advance.

  0 Comments

Sign in to comment.

Accepted Answer

Jordan Ross
Jordan Ross on 13 Jan 2017
Edited: MathWorks Support Team on 28 Nov 2018
Hello,
As I understand, you are trying to resize your window using the following command:
>> set(gcf, [ four values])
However, you forgot to specify the name of the ‘Position’ property. For example, here’s how to set the figure to be 500 pixels by 400 pixels:
>> set(gcf, 'Position', [100, 100, 500, 400])

  4 Comments

Show 1 older comment
PkStefan
PkStefan on 16 Apr 2020
100 and 100 (x and y) define the distance from the lower-left corner of the screen to the lower-left corner of the figure.
Oladunjoye Awoga
Oladunjoye Awoga on 16 Apr 2020
PkStefan is correct. But in addition I find it more useful to do the following
g = figure(figure window number);
g.Resize = 'off';
Doing this solved all the initial problem of fixed window problem. Then the figure window responds to all other commands such as that given in previous answers above.
Grzegorz Lippe
Grzegorz Lippe on 30 Oct 2020 at 14:39
'Position' refers to the inner part of the figure. How can I adress the whole Window size?
scr_siz = get(0,'ScreenSize') ;
figure(floor([scr_siz(3)/2 scr_siz(4)/2 scr_siz(3)/2 scr_siz(4)/2])) ;
The example above creates a figure in the upper right corner, but the menu and control elements are out of the screen boundaries.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!