If Statement Using Text in a Table

조회 수: 15 (최근 30일)
Jay
Jay 2019년 7월 21일
댓글: Walter Roberson 2019년 7월 23일
What commands can I use in the following if statement to specify blank element overwrite?
% Run throught the table of 10 rows
for i = 1:10
% The word "REMOVE" has been used in a previous condition subroutine to specify the row removal in this if statment
if strcmp("REMOVE",table1(i,1)) == 1
% Emptys rows
table1(i,:) = []
else
end
end
The subroutine is executed and the table rows are not being emptied when true

채택된 답변

madhan ravi
madhan ravi 2019년 7월 21일
T=table({'asdsa';'REMOVE'}); % example
idx=strcmp(T{:,1},"REMOVE");
T(idx,:) = [] % remove those rows
  댓글 수: 14
Jay
Jay 2019년 7월 23일
Thank you for explaining what that command does Walter.
The explanations by the more advanced contributors help a lot more in understanding commands that exceed the simpler commands in the Matlab documentation.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by