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일
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 Exchange에서 Loops 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