How can I change the default units in GUIDE

5 views (last 30 days)
Yuval Cohen
Yuval Cohen on 10 Apr 2014
Answered: Robert Thomas on 30 Sep 2022
Hello, I use GUIDE for many of my GUIs. I like using 'pixels' for the figure and all uicontrols. Unfortunately, the default units are 'characters' and I have to manually change the unit value for every new uicontrol I add.
Is there a way to change the default units?
Thank you, Yuval

Answers (4)

Image Analyst
Image Analyst on 17 Apr 2014
You can't change the default as far as I know. You need to set up each one. However they don't need to be done one at a time in the Property Inspector, and you don't need to write something into every CreateFcn. You can set them all as a group (well almost all). What you can do is to drag a box around all the controls on your figure to select all of them. Then double-click on any one of them to bring up the Property Inspector. It will list only those properties that apply to all of them, and some will be missing because some controls don't have certain properties. Fortunately "Units" is one of those that will be shown. You can change the units to pixels for all the controls that you have selected, then close the property inspector. The only ones it won't apply to are those controls that are located inside a panel (group box). For those you have to set them one at a time.

nl2605 on 17 Apr 2014
In the CreateFcn you can change the units as you want them to be. But yes, you will have to write it in every CreateFcn of your figure components.

Sean de Wolski
Sean de Wolski on 17 Apr 2014
In general, you can do this if you were making programmatic UIs. However, GUIDE sets its own defaults that can't be changed to my knowledge.
With a regular figure:
hFig = figure;
I would recommend IA's approach. You can also right click a graphics component in GUIDE to make a copy of it. That way you change the properties once, right click and drag to get an identical object.
  1 Comment
Image Analyst
Image Analyst on 17 Apr 2014
Neat trick (right click and drag). I was always using control c, control v to create a copy of a control.

Sign in to comment.

Robert Thomas
Robert Thomas on 30 Sep 2022
majority of students find to be quite uninteresting and challenging It is because they place a greater emphasis on raising their grades than on developing their creativity It is true that you must adhere to the instructions provided by your professor sad story ideas There are some times when in life things do not go the way we want We have no choice but to accept them as they are or deal with them.


Find more on Migrate GUIDE Apps in Help Center and File Exchange


Community Treasure Hunt

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

Start Hunting!