How to select a specific cell in UITable?

There is an input and I want to get the other values in the row where this input is equal to one of the values in the first column of the UITable.
I think l need something like:
idx = UITable.ColumnName.SerialNumber==3
Thanks for your help!

 採用された回答

Taylor
Taylor 2023 年 12 月 4 日

0 投票

[rows, ~] = find(value == UITable.Data)
UITable.Data(r,:)

7 件のコメント

piston_pim_offset
piston_pim_offset 2023 年 12 月 4 日
It says:
Undefined function 'eq' for input arguments of type 'table'
Walter Roberson
Walter Roberson 2023 年 12 月 4 日
If UITable is a uitable, then UITable.Data would be a table() object, and you would do something like
uit = UITable.Data;
mask = value == uit.SerialNumber;
selected_rows = uit(mask,:);
piston_pim_offset
piston_pim_offset 2023 年 12 月 4 日
編集済み: piston_pim_offset 2023 年 12 月 4 日
Actually it is app.UITable, but l'll try this in a few minutes.
Got en error @Walter Roberson:
Unrecognized method property or field 'SerialNumber'
Taylor
Taylor 2023 年 12 月 4 日
UITable.Data can return any of the following types: table array, numeric array, logical array, cell array, string array, or cell array of character vectors. If you run the following command you will be able to tell what type of data you are working with:
uit = app.UITable.Data;
class(uit)
"app.UITable" implies you are working within App Designer. Within App Designer, components/functions/properties specific to the app are called with the prefix "app.". It's just a syntax error, so if you add the prefix to you code that should allow you to interface with the UITable.
piston_pim_offset
piston_pim_offset 2023 年 12 月 5 日
I have tried your correction but errors are the same.
Walter Roberson
Walter Roberson 2023 年 12 月 5 日
Once you have done
uit = app.UITable.Data;
then what shows up for
uit.Properties.VariableNames
piston_pim_offset
piston_pim_offset 2023 年 12 月 5 日
I finally made it work by combining your answers @Taylor and @Walter Roberson Thanks a lot for your help!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by