How to display units in table in a GUI?

18 ビュー (過去 30 日間)
Jouni Lindqvist
Jouni Lindqvist 2019 年 10 月 30 日
編集済み: Subhadeep Koley 2020 年 5 月 8 日
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

回答 (1 件)

Subhadeep Koley
Subhadeep Koley 2019 年 11 月 5 日
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 件のコメント
Subhadeep Koley
Subhadeep Koley 2020 年 5 月 8 日
編集済み: Subhadeep Koley 2020 年 5 月 8 日
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];

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by