How to do i pull certain entries out of a table when another cell column meets a certain condition?
조회 수: 1 (최근 30일)
이전 댓글 표시
It's a long question but what I want to do is very simple.
Say i have a table that was imported.
T=5×6 table
A B
_ _________
1 'string 1'
2 'string 2'
3 '5'
4 '6'
When i import this table it converts the 5 and 6 to strings in cells. I just want to return everything in A that doesn't have a 'string*' in column b. 3; and 4 in this case.
Problem for me is that this does not work:
T.A(T.B ~= 'string*')
i get: "Undefined operator '~=' for input arguments of type 'table'."
댓글 수: 0
답변 (1개)
Harsh
2018년 10월 4일
As an example you can try this:
>> T = table([1:4]', {'string 1'; 'string 2'; '5'; '6'}, 'VariableNames', {'A', 'B'} );
>> res = T.A(~(strncmp(T.B, 'string', 6)), :);
댓글 수: 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!