How to display units in table in a GUI?

23 Ansichten (letzte 30 Tage)
Jouni Lindqvist
Jouni Lindqvist am 30 Okt. 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

Antworten (1)

Subhadeep Koley
Subhadeep Koley am 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 Kommentar
Subhadeep Koley
Subhadeep Koley am 8 Mai 2020
Bearbeitet: Subhadeep Koley am 8 Mai 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];

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by