MATLAB: [uitable] Insert a table as a subplot

MATLABplotsubplotuitable

I am trying to insert an 8×8 table next to an existing plot. Although both of them appear in the same figure(4), the table cannot be moved or edited, therefore I cannot illustrate the results as I want to.
The code I use is provided below:
f=figure(4)
% create the data
d = od_table;
% Create the column and row names in cell arrays
cnames = {'1','2','3','4','5','6','7','8'};
rnames = {'1','2','3','4','5','6','7','8'};
% Create the uitable
t = uitable(f,'Data',d,...
'ColumnName',cnames,...
'RowName',rnames,...
'ColumnWidth',{30})
The ideal solution for me would the table to be able to be moved around the figure with fixed size, titles etc. As a 'movable legend'.

Best Answer

I'm not entirely sure what you are describing as the ideal solution. Are you asking for a click and drag ability to dynamically move and resize items? I can't think of something right off the bat for how to accomplish that but if you want to move and resize the uitable you can do something like this
f=figure(4)
% create the data
% Create the column and row names in cell arrays
cnames = {'1','2','3','4','5','6','7','8'};
rnames = {'1','2','3','4','5','6','7','8'};
% Create the uitable
t = uitable(f,'Data',rand(8),...
'ColumnName',cnames,...
'RowName',rnames,...
'ColumnWidth',{30})
subplot(2,1,1),plot(3)
pos = get(subplot(2,1,2),'position');
delete(subplot(2,1,2))
set(t,'units','normalized')
set(t,'position',pos)
Where i get and set the uitable to fit inside subplot(2,1,2) position.