How to implement Uistyle in an output table

6 次查看(过去 30 天)
Hello, I'd like to implement Uistyle in my table, which is an output of several equations:
I'd like to apply uistyle to emphasize some parts like this :
My table-generating code:
FloodIntensity = table(hPipe, Aflow, Qchannel, 'VariableNames',{'h' 'A' 'Q [m3/s]'} )
I have read documentation, but they only provide examples for imported csv. data or some rand-generated ones.
Can anyone show me an example, how to build Uistyle around such table, as mine?

采纳的回答

Simon Chan
Simon Chan 2022-1-29
Actually the documentation describe a lot of examples and I just copy some of them as follows:
Create a uitable on uifigure:
fig = uifigure;
uit = uitable(fig,'Data',FloodIntensity);
(1) Add background color to column 1 & 3:
s1 = uistyle('BackgroundColor','cyan'); % Create the uistyle
addStyle(uit,s1,'column',[1 3]); % Add style on column 1 and 3 only
(2) Change the fontcolor and fontweight for 0.5<A<1
idx.fontcolor = 0.5<FloodIntensity.A & FloodIntensity.A<1; % Find the index
row = find(idx.fontcolor); % Row number
col = repelem(2,length(row))'; % Column number
s2 = uistyle('FontColor','blue','FontWeight','bold'); % Define the uistyle, color is blue and bold type
addStyle(uit,s2,'cell',[row col]); % Add style on each cell satisfy your condition
(3) Horizontal alignment for the entire table
s3 = uistyle('HorizontalAlignment','center');
addStyle(uit,s3);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop uifigure-Based Apps 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by