How to resize UI table to fill window?
35 views (last 30 days)
Show older comments
I am outputting a UI table within matlab and it does not fill the entire window, I have to scroll over to see all the colums of data. I have tried to change the Units to "normalized" but that has not changed it. What else can I do?
Thank you for your help!

Answers (1)
Riccardo Scorretti
on 29 Apr 2022
Hi Logan,
setting Units to normalized is not enough: you have to modify also the property Position:
LastName = {'Sanchez';'Johnson';'Li';'Diaz';'Brown'};
Age = [38;43;38;40;49];
Smoker = logical([1;0;1;0;1]);
Height = [71;69;64;67;64];
Weight = [176;163;131;133;119];
BloodPressure = [124 93; 109 77; 125 83; 117 75; 122 80];
T = table(LastName,Age,Smoker,Height,Weight,BloodPressure)
fig = uifigure;
uit = uitable(fig, 'Data', T, 'units', 'Normalized', ...
'Position', [0 0 1 1]);

1 Comment
Riccardo Scorretti
on 29 Apr 2022
In this example, try to have a look to the properties of uit: you will discover a lot of ways of tweaking the appearence of the table:
>> uit
uit =
Table with properties:
Data: [5×6 table]
ColumnWidth: 'auto'
ColumnEditable: []
CellEditCallback: ''
Position: [0 0 1 1]
Units: 'normalized'
Show all properties
BackgroundColor: [2×3 double]
BeingDeleted: off
BusyAction: 'queue'
ButtonDownFcn: ''
CellEditCallback: ''
CellSelectionCallback: ''
Children: [0×0 handle]
ColumnEditable: []
ColumnFormat: {}
ColumnName: {6×1 cell}
ColumnSortable: []
ColumnWidth: 'auto'
ContextMenu: [0×0 GraphicsPlaceholder]
CreateFcn: ''
Data: [5×6 table]
DeleteFcn: ''
DisplayData: [5×6 table]
DisplayDataChangedFcn: ''
Enable: 'on'
Extent: [0 0 0.5357 0.7143]
FontAngle: 'normal'
FontName: 'Helvetica'
FontSize: 12
FontUnits: 'pixels'
FontWeight: 'normal'
ForegroundColor: [0 0 0]
HandleVisibility: 'on'
InnerPosition: [0 0 1 1]
Interruptible: on
KeyPressFcn: ''
KeyReleaseFcn: ''
Layout: [0×0 matlab.ui.layout.LayoutOptions]
Multiselect: on
OuterPosition: [0 0 1 1]
Parent: [1×1 Figure]
Position: [0 0 1 1]
RearrangeableColumns: off
RowName: {}
RowStriping: on
Selection: []
SelectionChangedFcn: ''
SelectionType: 'cell'
StyleConfigurations: [0×3 table]
Tag: ''
Tooltip: ''
Type: 'uitable'
Units: 'normalized'
UserData: []
Visible: on
By the way, never copy program codes as images: copy them at least as text, and preferably as code (by using the appropriate icon). You will get much more help; it is very nasty to have to rewrite codes by hand.
See Also
Categories
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!