Obtain all table elements from a column which correspond to certain string in another column
조회 수: 1 (최근 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!