How do I add a Table in App Designer?

161 ビュー (過去 30 日間)
Sree
Sree 2018 年 11 月 16 日
コメント済み: Adam Danz 2023 年 5 月 9 日
With due respect, the instructions for App Designer are at best counter-intuitive and hermetic. For example, how to create a Table with 3 columns and 3 rows (besides the row of column headings), name columns AND rows, and populate the cells with Default values. Make these cell data entries editable by the user when running the app. The app sould take these Table data (and other data from the Slider, Knob, etc.), run a code that generates a plot.
I am stuck in trying to add Row Names. The User Community advises I need to add Table data first. But there seems to be no place in Design View to add such data!
  11 件のコメント
Adam Danz
Adam Danz 2018 年 11 月 20 日
If you share that snippet of code I might be able to help. Also, I'll move the response to the 'answers' section so others may find it useful in the future.
ibenitoseb
ibenitoseb 2020 年 3 月 10 日
Here is a tutorial on adding rows and columns to tables in app designer:

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

採用された回答

Adam Danz
Adam Danz 2018 年 11 月 20 日
編集済み: Adam Danz 2018 年 11 月 20 日
To add data to a UItable in App Designer, use the startupFcn() after creating the table in the UI.
  1. From the App Designer in design mode, right click anywhere on your app background, hover your mouse over 'callbacks', and add a startupFcn callback.
  2. Go to Code View and you'll see the startupFcn. Add your data to your table there. Refer to the documentation below to change other properties of the table.
app.UITable.Data = {1 2 3 4};
  5 件のコメント
Luca Re
Luca Re 2023 年 5 月 8 日
I read your link but couldn't find it
Adam Danz
Adam Danz 2023 年 5 月 9 日
In the link, see the image in the first step. You must select your app in the component browser.

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

その他の回答 (2 件)

Paul Macey
Paul Macey 2020 年 6 月 17 日
編集済み: Paul Macey 2020 年 6 月 17 日
Should really have a way to initalize in properties with at least one empty row.....
Here's what I did in the app startupFcn
app.ColorsUITable.Data = cell(1,length(app.ColorsUITable.ColumnName));
  1 件のコメント
Adam Danz
Adam Danz 2020 年 6 月 18 日
That is the way to initialize a table with 1 empty row.
For some data types you can use <missing>

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


Eric Sargent
Eric Sargent 2020 年 12 月 9 日
You can edit the RowName, ColumnName and ColumnEditable Properties of a UITable from the Property Inspector of App Designer.
You cannot add Data to a UITable from the Design View of App Designer, you will need to add the data in a StartupFcn (or other callback). For example
function startupFcn(app)
app.UITable.Data = rand(2,4);
end
Will result in:
  2 件のコメント
Kristina Francke
Kristina Francke 2023 年 2 月 1 日
編集済み: Kristina Francke 2023 年 2 月 1 日
what if i want to add a value in Column 1 row Two only?
Adam Danz
Adam Danz 2023 年 2 月 1 日
編集済み: Adam Danz 2023 年 2 月 1 日
app.UITable.Data(2,1) = value;

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by