Adapting Matlab GUI to Screen Resolution

In summary: box to be positioned at the bottom right corner of the figure window and resized to take up half of the window's width and height (400x200 pixels).
  • #1
big man
254
1
I have this Matlab GUI and I need assistance with making it independent of screen resolution. What I mean by this is that I want it to resize itself according to whatever the screen resolution is. Now I know how to do this for the actual GUI figure window, but none of the objects within the window seem to resize/relocate accordingly. So what I have is text boxes that cut off text if the screen resolution is changed.

I will post pictures of the problem and code (if you want the code that is) when I get home, but for now do any of you know if it is possible to have the objects (such as axes, text boxes and push buttons) in a GUI resize themselves depending on the screen resolution?
 
Physics news on Phys.org
  • #2
Yes, it is possible to have objects in a Matlab GUI resize themselves depending on the screen resolution. The recommended way to do this is to use the 'units' property of each object. This property allows you to specify the units used when positioning and sizing the object, such as pixels, points, inches, centimeters, etc. By setting the 'units' property to 'normalized', the object will automatically resize itself relative to the size of the figure window.

For example, if you have a text box inside a figure window that is 800x400 pixels, you can set its 'units' property to 'normalized' and then set the 'position' property to [0 0 0.5 0.5]. This will cause the text box to be positioned at the top left corner of the figure window and resized to take up half of the window's width and height (400x200 pixels).

You can also use the 'Position' property to resize/relocate an object relative to its parent container, such as a panel or figure window. For example, if you want to position a text box at the bottom right corner of a figure window that is 800x400 pixels, you can set its 'units' property to 'normalized' and then set the 'position' property to [0.75 0.25 1 1]. This will cause the text
 
  • #3


I understand the importance of having a flexible and adaptable GUI for scientific applications. It is essential to ensure that the GUI can be used on different devices with varying screen resolutions. I would suggest using the "units" property for each object in the GUI. By setting the units to "normalized," the objects will resize themselves according to the size of the figure window, regardless of the screen resolution. This will ensure that all the objects within the GUI are proportionally resized when the screen resolution is changed.

Additionally, you may also need to adjust the position and size of the objects using the "position" property to ensure they are correctly placed within the resized figure. This can be done by using a combination of relative and absolute values for the position.

I would also recommend testing the GUI on different screen resolutions to ensure that all objects are properly resized and visible. It may also be helpful to consult the Matlab documentation or reach out to the MathWorks support team for further assistance with adapting your GUI to different screen resolutions.

In conclusion, by using the "units" and "position" properties, you should be able to make your Matlab GUI independent of screen resolution and ensure that all objects are properly resized and visible on different devices. I hope this helps in solving your issue.
 

1. How do I ensure that my Matlab GUI looks good on different screen resolutions?

In order to adapt your Matlab GUI to different screen resolutions, you can use the "pixels per inch" (PPI) setting. This setting allows you to adjust the size of your GUI elements based on the PPI of the screen, so that it appears consistent across different resolutions.

2. Can I use a fixed size for my GUI elements instead of using the PPI setting?

While you can use a fixed size for your GUI elements, it is not recommended as it may result in your GUI appearing too small or too large on different screen resolutions. It is best to use the PPI setting to ensure a consistent appearance.

3. Will adapting my GUI to screen resolution affect the functionality of my code?

No, adapting your GUI to screen resolution should not affect the functionality of your code. It only changes the appearance of your GUI elements to make them fit better on different screen sizes.

4. How can I test my GUI on different screen resolutions?

You can test your GUI on different screen resolutions by changing the resolution of your display or by using a virtual machine with a different resolution. You can also use the "position" property in Matlab to specify the size and location of your GUI elements and see how they appear on different resolutions.

5. Can I use different layouts for different screen resolutions?

Yes, you can use different layouts for different screen resolutions by using the "uisize" function in Matlab. This allows you to specify different sizes for your GUI elements based on the screen resolution, giving you more control over the appearance of your GUI on different screens.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
750
  • Programming and Computer Science
Replies
24
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
16K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
20K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
Back
Top