Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Finding corresponding term from a uitable

1 回表示 (過去 30 日間)
vedesh Mohit
vedesh Mohit 2020 年 2 月 18 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I have created the uitable as seen in the attached. I have extracted the data from the table. I have sorted through the "TO" column to find the value "I3" and I would like to get the corresponding term when it finds I3, which would be "InputB". This is what i have attempted. So another example is if I search for "I20", the corresponding term would be "O6".
Result3 = get(uit3, 'data');
s='I3';
tf=strcmpi(s,Result3(1:end,2))

回答 (1 件)

Jakob B. Nielsen
Jakob B. Nielsen 2020 年 2 月 19 日
If I recall, strcmpi needs string arrays, character vectors or cell arrays of character vectors as inputs, whereas you give it a table as an input. Therefore, it will only ever return false.
Try combining logic indexing and table2cell, which enables your strcmpi to function:
Result3 = get(uit3, 'data');
s='I3';
Result3(strcmpi(table2cell(Result3(:,2)),s),1)
This will print out the value from the row in Result3 for which your logic is true, and the 1st column. In the example I would expect InputB to come out.

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by