How to display units in table in a GUI?

16 visualizzazioni (ultimi 30 giorni)
Jouni Lindqvist
Jouni Lindqvist il 30 Ott 2019
It used to be possible to make a second row in a table header. This was useful for writing out units, for example. This does not seem to be possible in the app designer apps. Is there another way to display units in a table in a GUI made in app designer?
Thank you in advance

Risposte (1)

Subhadeep Koley
Subhadeep Koley il 5 Nov 2019
Hi Jouni,
It seems not possible to add a second row in the table header in App Designer. Also, when you create a table in app designer. It gets created under uifigure parent and column names are restricted to one line of text. Therefore, you cannot add a second line for the units / examples also.
But when you create a table directly without specifying any parent (using the uitable() function) then default parent is a MATLAB figure and the uitable is created for which column name property supports "|" to get the multi-line column name, where the second line can be used for the units / examples.
  1 Commento
Subhadeep Koley
Subhadeep Koley il 8 Mag 2020
Modificato: Subhadeep Koley il 8 Mag 2020
One workaround:
Paste the following code in the startupFcn callback of your app to create a table with multi-line column header. Here, sprintf(__) with \n escape sequence is used to create multi-line column header.
% Create the UITable component
UITable = uitable(app.UIFigure);
% Specify row and column name
UITable.ColumnName = {sprintf('First\nEntry'); sprintf('Second\nEntry'); sprintf('Third\nEntry')};
UITable.RowName = {};
% Populate the table with some random data
UITable.Data = rand(3);
% Set the table position
UITable.Position = [148 224 302 108];

Accedi per commentare.

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by