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 CenterFile Exchange에서 Dialog Boxes에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by