Azzera filtri
Azzera filtri

How to implement Uistyle in an output table

5 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Simon Chan
Simon Chan il 29 Gen 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 Commento
KarolN
KarolN il 29 Gen 2022
This is the most exhaustive answer I could possibly hoped for. Thanks!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Develop uifigure-Based Apps in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by