Update on filtering table
조회 수: 1 (최근 30일)
이전 댓글 표시
I posted a question on here the other day about filtering and it hasn't been answered yet, i made some changes to it but still have issue so I'm hoping if there are two posts one will be answered. So i made the loop to store which rows have values over the cut off value, the only problem is when row is under the cut off value a zero is put into the rows delt vector which screws up the deleteing of rows since the Table cannot have a zero input.
Filter=app.CutOffValueEditField.Value;
n=size(app.t,1);
if(app.LowPassButton.Value)
for i=1:n
if app.UITable3.Data(i,app.ColumnNumberbeingevalulatedEditField.Value)>=Filter
rowsdelt(i)=i
end
end
app.UITable3.Data(rowsdelt,:)=[];
댓글 수: 0
채택된 답변
Cris LaPierre
2021년 3월 1일
편집: Cris LaPierre
2021년 3월 1일
Use logical indexing instead. You can do that without the for loop. (untested)
if ...
rowsdelt = app.UITable3.Data(:,app.ColumnNumberbeingevalulatedEditField.Value)>=Filter;
app.UITable3.Data(rowsdelt,:)=[];
end
Note that you'll want the delete command inside the if statement or you'll get an error about undefined variable rowsdelt anytime app.lowpassbutton.value is false.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!