How to remove all the rows containing a substring from a table?

조회 수: 4 (최근 30일)
Chiara Scarpellini
Chiara Scarpellini 2021년 8월 10일
편집: Stephen23 2021년 8월 11일
I need to remove all the rows containing the substring Downstream from the table.

채택된 답변

Wan Ji
Wan Ji 2021년 8월 11일
Assume the table is named 'myTable'.
Then
p = arrayfun(@(i)strncmpi(myTable.beregnings{i}(end:-1:1),'maertsnwod',10),(1:1:size(myTable,1))','uniform',true);
newTable = myTable(~p,:);
Your newTable is therefore what you want!

추가 답변 (1개)

Stephen23
Stephen23 2021년 8월 11일
편집: Stephen23 2021년 8월 11일
Simple and efficient MATLAB approach:
A = [0;1;2;3;4];
B = ["cat";"hat";"sat_Downstream";"fat";"rat_Downstream"];
C = [5;6;7;8;9];
T = table(A,B,C)
T = 5×3 table
A B C _ ________________ _ 0 "cat" 5 1 "hat" 6 2 "sat_Downstream" 7 3 "fat" 8 4 "rat_Downstream" 9
X = contains(T.B,'Downstream'); % or endsWith
T(X,:) = []
T = 3×3 table
A B C _ _____ _ 0 "cat" 5 1 "hat" 6 3 "fat" 8

카테고리

Help CenterFile Exchange에서 Develop 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