MATLAB: How to get the GUI to resize properly on different displays

cross platform compatibilitydisplaysguiguideMATLAB

I created a GUI that does not seem to re-size correctly on different computer displays. The GUI fig is defined in GUIDE and I have checked to see that all of the units are "character" in the property inspector and in the GUI options I also have the Resize behavior set to: Non-resizable.
I am using the following code to get the screen resolution and define the window size and position, but the figure does not hold the same size on different displays and will chop off information.
What approach do I need to take to get this to work? How should I modify the code below or do I have settings wrong in the GUIDE Fig?
Thanks Ian
SC = get(0, 'ScreenSize')
MaxMonitorX = SC(3)
MaxMonitorY = SC(4)
% Set the figure window size values
MainFigScale = 1; % Change this value to adjust the figure size
MaxWindowX = round(MaxMonitorX*MainFigScale)*1200/MaxMonitorX*1.02;
MaxWindowY = round(MaxMonitorY*MainFigScale)*800/MaxMonitorY;
TabOffset = 0; % This value offsets the tabs inside the figure.
ButtonHeight = 40;
PanelWidth = MaxWindowX-2*TabOffset+4;
PanelHeight = MaxWindowY-ButtonHeight-2*TabOffset;
ButtonWidth = round((PanelWidth-NumberOfTabs)/NumberOfTabs);
% Set the color varables.
White = [1 1 1]; % White - Selected tab color
BGColor = .9*White; % Light Grey - Background color
% Create a figure for the tabs
hTabFig = fig; %Use GUIDE Fig
set(hTabFig, 'Position',[ MaxWindowX/30, MaxWindowY/20, MaxWindowX/6, MaxWindowY/16]);

Best Answer

Don't set it to non-resizable but set the units of everything to 'normalized'.
Related Question