MATLAB Answers

How do I add a Table in App Designer?

483 views (last 30 days)
Sree
Sree on 16 Nov 2018
Commented: Adam Danz on 18 Jun 2020
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 Comments

Show 8 older comments
Sree
Sree on 20 Nov 2018
Thanks. By coincidence, I tried the satrtupFCN approach before your suggestion! It works, but just one glitch remains. The Table appears in a new window (instead of the main window where the other items, like sliders are normally dragged into). Getting there! Thanks again for your attention.
Adam Danz
Adam Danz on 20 Nov 2018
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 on 10 Mar 2020
Here is a tutorial on adding rows and columns to tables in app designer:

Sign in to comment.

Accepted Answer

Adam Danz
Adam Danz on 20 Nov 2018
Edited: Adam Danz on 20 Nov 2018
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 Comment

Shawn McLean
Shawn McLean on 12 Apr 2020
Uhhh. Wow. Greaaate answer.

Sign in to comment.

More Answers (1)

Paul Macey
Paul Macey on 17 Jun 2020
Edited: Paul Macey on 17 Jun 2020
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 Comment

Adam Danz
Adam Danz on 18 Jun 2020
That is the way to initialize a table with 1 empty row.
For some data types you can use <missing>

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!