uicontrol doesn't work in Matlab 2023a

figure;pauseButton=uicontrol('Style','pushbutton',...
'String','pause','Position',[2000 60 100 100],...
'Callback',@(src,event)uiwait);
This code is supposed to work but it doesn't have any button showing up in Matlab 2023a, why?

 Accepted Answer

The button position you give is way off push the button outside the universe. This happens with all MATLAB.
figure;pauseButton=uicontrol('Style','pushbutton',...
'String','pause','
Callback',@(src,event)uiwait);

6 Comments

Thanks a lot for the answer. This seems to be caused by using two different computers with different screen resolutions. Is there any smart way of getting around this issue of adjusting these position parameters for different computers? I would like to put several such buttons and preferably on the right bottom corner.
Bruno Luong
Bruno Luong on 15 Apr 2024
Edited: Bruno Luong on 15 Apr 2024
I never found an ideal and easy way to adjust GUI with different screen resolution but you should set the unit to "normalized" to start with. The issue is not all size position looks good for single unit, sometime you have to mix them.
got it thanks! how to set the unit to "normalized"?
Bruno Luong
Bruno Luong on 16 Apr 2024
Edited: Bruno Luong on 16 Apr 2024
Every grapic object has a rectangle bounding box and the property 'UNITS' and 'POSITION' .
The POSITION you set or get is expressed on unit UNITS. and related to the parent container they define where the object is located and how large and wide the size is.
You set UNITS exexactly like you set POSITION in your command UICONTROL (
Now I got how to set units to normalize, but after that when I specify the position to be [2000 60 100 100] it's still out of scope.
You still don't understand the concept of Unit, if you do you would never use Position outside 0, 1 in normalized units
Google and read. Sorry but I'll not here to correcct every single mistake you make by randomly do in your code.

Sign in to comment.

More Answers (0)

Categories

Find more on App Building in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!