- https://www.mathworks.com/help/releases/R2022a/matlab/ref/rows2vars.html
- https://www.mathworks.com/help/releases/R2022a/matlab/ref/uistyle.html
- https://www.mathworks.com/help/releases/R2022a/matlab/ref/matlab.ui.control.table.addstyle.html
How to change a UITable displayed vertically in MATLAB App Designer to a horizontal display?
16 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ali Taheri
am 16 Feb. 2022
Kommentiert: Ali Taheri
am 9 Sep. 2024
Hello;
I am using app designer and wanted to create a table but I want it to be displayed horizontally. My program is as follows:
Num=1:10;
B= 2*Num;
t2=table(Num',B');
app.UITable.ColumnName = {'Number','B'};
app.UITable.Data =t2;
And when I Run in App Designer, the result is as follows:
But I want the table to be displayed as follows (horizontally) and also data aligned in center of cells.
Thank you for your time to reply.
0 Kommentare
Akzeptierte Antwort
Sreeram
am 3 Sep. 2024
Hi Ali,
You can use the MATLAB function “rows2vars” to display the table horizontally. To align the data in the center of the cells, you can use “uiStyle” and “addStyle”.
Here’s the implementation for your reference:
Num = 1:10;
B = 2*Num;
t2 = table(Num',B');
t2.Properties.VariableNames = {'Number','B'};
t2transpose = rows2vars(t2); % Transposing the data
app.UITable.ColumnName = []; % To hide column titles
app.UITable.Data = t2transpose;
% Centering the data
s = uistyle('HorizontalAlignment','center');
addStyle(app.UITable,s)
Here’s how the output will be:
You may read about “rows2vars”, “uistyle”, and “addStyle” here:
I hope it helps!
7 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!