MATLAB Answers

How to make program window and figure centered using GUI and varargout = guidefunc(action, varargin).

2 views (last 30 days)
Moshe Meyers
Moshe Meyers on 16 Dec 2019
Edited: Rik on 17 Dec 2019
I have been given this code to edit and make usable for an upcoming experiment. However, i am having issues loading the window fullscreen, and whenn it does load fullscreen the interactive figures are placed in the bottom left instead of the center of the screen. How can i code this to run fullscreen and have the interactive figure in the center of the screen. I have attatched an image for reference to what i am talking about. I have also attetched an image of what i beleive to be the code in control of the placement, so i would like to know what i change.
Thank you
Screen Shot 2019-12-16 at 12.36.48 pm.png
Screen Shot 2019-12-16 at 12.33.13 pm.png

  7 Comments

Show 4 older comments

Sign in to comment.

Accepted Answer

Rik
Rik on 17 Dec 2019
Since it apparently solved your issue, I'll move my comment to the answer section:
As you can see in the first screenshot the Units property of your figure is Pixels, not Normalized. But actually, that is not relevant. The buttons and other objects have a position relative to their container. That container is very likely to be the figure. That means their Position is relative to the figure. If those are in Pixel units as well, that means their position is encoded as a specific number of pixels away from the lower left corner. If you change the Units property to Normalized for all your buttons and other objects, they will be defined as a percentage of the figure width and height.
Note that changing the Units to Normalized also means that the aspect ratio of your buttons will change if the aspect ratio of your figure changes. Note that you might have to modify the font size as well to prevent large buttons with tiny text.
NB: apply these changes through the GUIDE interface, not in the fig file directly. If you would have been handed a GUI built from code, this would be a lot easier, but now you must either recreate the fig from code, or stick to GUIDE.

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.