Failed to "dot indexing" the data from uitable

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.

 採用された回答

Steven Lord
Steven Lord 2022 年 11 月 10 日

2 投票

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 件のコメント

Michael Au
Michael Au 2022 年 11 月 15 日
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.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

製品

リリース

R2022b

質問済み:

2022 年 11 月 10 日

コメント済み:

2022 年 11 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by