Obtain all table elements from a column which correspond to certain string in another column
4 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I have a table with two columns. The first is a column of strings & the second numbers. I want to obtain all the elements in column 2 that correspond to the string 'Bonus' in column 1.
How can I do this?
Thank you
0 件のコメント
採用された回答
Voss
2023 年 3 月 5 日
% a table
str = {'Onus';'Bonus';'Loan us';'On us';'Bonus';'Money';'Bonus'};
num = [1;2;3;2;4;3;1];
t = table(str,num)
% get the numbers corresponding to 'Bonus'
bonus_nums = t{strcmp(t{:,1},'Bonus'),2}
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!