To set row-name column width to auto-fit the row-label-width:
If your goal is to fit the row name column to the width of the labels, create the uitable within a uifigure. The row-name column is auto-fitted in uifigures but not in regular figures. Also, use tiledlayout instead of subplot -or- turn off the AutoResizeChildren property of the uifigure to avoid an error produced by subplot.
tiledlayout & uifigure demo
Also note the use of axis and figure handles.
LastName = {'Smith';'Johnson';'Williams';'Jones';'Brown'};
Height = [71;69;64;67;64];
Weight = [176;163;131;133;119];
T = table(Age,Height,Weight,'RowNames',LastName);
tlo = tiledlayout(fig,2,1);
hUI = uitable(fig,'Data',T{:,:},'ColumnName',T.Properties.VariableNames,...
'RowName',T.Properties.RowNames,'Units', 'Normalized', 'Position',hAx(1).Position ,...
'ColumnWidth' , {100,100,100});
subplot & uifigure demo
Also note the use of axis and figure handles.
fig = uifigure('AutoResizeChildren','off');
hAx(1) = subplot(2,1,1,'Parent',fig);
hUI=uitable(fig,'Data',T{:,:},'ColumnName',T.Properties.VariableNames,...
'RowName',T.Properties.RowNames,'Units', 'Normalized', 'Position',hAx.Position , ...
'ColumnWidth' , {100,100,100});
hAx(2) = subplot(2,1,2,'Parent',fig);
To control width of row-name column:
I am not aware of a method that directly sets the column width of the row name. A workaround is to move the row names into column 1 of the data itself and then format that colum to make it look similar to the row-name column using uistyle & addStyle (requires Matlab >=r2019b). This requires you to use uifigure. Remember to index the table data by offsetting the column numbers by 1 to account for the row names.
The upper table is the default table with a row-name column. The lower table is without a row-name column but with formats column 1 to make it look like a row-name column.
tlo = tiledlayout(fig,2,1);
hUI=uitable(fig,'Data',T{:,:},'ColumnName',T.Properties.VariableNames,...
'RowName',T.Properties.RowNames,'Units', 'Normalized', 'Position',hAx(1).Position , 'ColumnWidth' , {100,100,100});
C = [T.Properties.RowNames, table2cell(T)];
hUI2=uitable(fig,'Data',C,'ColumnName',[{''},T.Properties.VariableNames],...
'RowName',[],'Units', 'Normalized', 'Position',hAx(2).Position , 'ColumnWidth' , {65,100,100,100});
colStyle = uistyle('BackgroundColor',hUI2.BackgroundColor(2,:),'FontWeight','bold');
addStyle(hUI2,colStyle,'column',1)