How to implement Uistyle in an output table

10 vues (au cours des 30 derniers jours)
KarolN
KarolN le 29 Jan 2022
Commenté : KarolN le 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?

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Develop uifigure-Based Apps dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by