How to display units in table in a GUI?

23 views (last 30 days)
Jouni Lindqvist
Jouni Lindqvist on 30 Oct 2019
Edited: Subhadeep Koley on 8 May 2020
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

Answers (1)

Subhadeep Koley
Subhadeep Koley on 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 Comment
Subhadeep Koley
Subhadeep Koley on 8 May 2020
Edited: Subhadeep Koley on 8 May 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];

Sign in to comment.

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!