MATLAB Answers

How do I add a Table in App Designer?

조회 수: 485(최근 30일)
Sree
Sree 2018년 11월 16일
답변: Eric Sargent 2020년 12월 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
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};
  댓글 수: 1
Shawn McLean
Shawn McLean 2020년 4월 12일
Uhhh. Wow. Greaaate answer.

댓글을 달려면 로그인하십시오.

추가 답변(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:

Community Treasure Hunt

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

Start Hunting!

Translated by