Failed to "dot indexing" the data from uitable

2 views (last 30 days)
Hi, I am trying to build a GUI with some simple user interactions.
Outside of GUI, I can do "Dot indexing" by referring to its "variablenames". For example, for a table T, I can use "T.Size" to obtain data under the variable name "Size". However, the trick does not work when it involves the GUI.
For "app.UITable", the data is stored under "app.UITable.Data". I tried "app.UITable_OSS1.Data.Size" but it returns an error.
"Dot indexing is not supported for variables of this type."
How could I adjust to make it work? Thanks.

Accepted Answer

Steven Lord
Steven Lord on 10 Nov 2022
The Data property of a uitable can contain different types of data, as stated on this documentation page. If you had stored a table array that contains a variable named Size in that uitable, I would expect that operation to work. But if you'd stored a non-table array in that uitable, it wouldn't.
A = [1 2 3; 4 5 6]
A = 2×3
1 2 3 4 5 6
T = array2table(A, 'VariableNames', ["Size", "Weight", "Temperature"])
T = 2×3 table
Size Weight Temperature ____ ______ ___________ 1 2 3 4 5 6
T.Size % Works
ans = 2×1
1 4
A.Size % Does not work
Dot indexing is not supported for variables of this type.
So either create / populate the uitable using a table array or modify your indexing based on whether the Data property istabular.
  1 Comment
Michael Au
Michael Au on 15 Nov 2022
Thank you! After checking with istabular, I realized I'm not dealing with a table.
I also mixed up the VariableNames (code) and the ColumnName (GUI). It's working well now.

Sign in to comment.

More Answers (0)

Categories

Find more on Tables in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!