Setting UI table size to start from the top row and have a scroll bar

1 回表示 (過去 30 日間)
Akshar Tandon
Akshar Tandon 2018 年 1 月 19 日
コメント済み: Greg 2018 年 1 月 19 日
Hello I am trying to plot data in a table but when I set it to size automatically, I lose my scroll bar and hence the ability to see data on top of the figure. The only way for me to do that is to increase my window size, which in this case is unreasonable. I want the output of this function to be a figure where the first row of the table is at the top and there is a scroll wheel on the right hand side.
clear;
figfig = figure('Name','Final Results','NumberTitle','off');clf;
X = rand(150,9);
XCell = cellstr(string(X));
A(1:150,1:9) = string("#FFFFFF");
A = cellstr(A);
outHtml = strcat('<html><table border=0 width=400 bgcolor=', ...
A, ... % Choose the appropriate color for each cell
'"><TR><TD>', ...
XCell, ... % Convert num data to cell of chars
'</TD></TR></body></html>');
u = uitable(figfig,'Data',outHtml);
table_extent = get(u,'Extent');
figure_size = get(figfig,'outerposition');
desired_fig_size = [figure_size(1) figure_size(2) table_extent(3)+15 table_extent(4)+65];
set(u,'outerposition',[1 1 table_extent(3) table_extent(4)])
set(figfig,'outerposition', desired_fig_size);
end
  2 件のコメント
Greg
Greg 2018 年 1 月 19 日
A = string("#FFFFFF");
Is redundant. The double quotes give you a string.
A(1:150,1:9)
Is also unnecessary, as strcat will apply implicit expansion to a scalar input.

サインインしてコメントする。

採用された回答

Greg
Greg 2018 年 1 月 19 日
Not sure why you're using HTML here...
u = uitable(figfig,'Data',outHtml,'Units','normalized','OuterPosition',[0,0,1,1]);
Then remove the other lines dealing with the uitable size/position.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by