How to implement Uistyle in an output table

9 Ansichten (letzte 30 Tage)
KarolN
KarolN am 29 Jan. 2022
Kommentiert: KarolN am 29 Jan. 2022
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?

Akzeptierte Antwort

Simon Chan
Simon Chan am 29 Jan. 2022
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);
  1 Kommentar
KarolN
KarolN am 29 Jan. 2022
This is the most exhaustive answer I could possibly hoped for. Thanks!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Develop uifigure-Based Apps finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by