How to delect the zero values in table
조회 수: 59 (최근 30일)
이전 댓글 표시
There is a table in matlab, I want to know how to delete the entire row with zero values?
Many thanks in advance.
댓글 수: 0
채택된 답변
the cyclist
2021년 5월 24일
If all of the table entries are numeric, then this will work:
% Create an example input table
x = [0; 1; 0; 2];
y = [0; 1; 0; 2];
z = [0; 0; 0; 0];
tbl = table(x,y,z)
% Identify rows with all zeros, by first converting to numeric
rowsToDelete = all(table2array(tbl)==0,2);
% Delete the rows
tbl(rowsToDelete,:) = []
추가 답변 (1개)
Fangjun Jiang
2021년 5월 24일
편집: Fangjun Jiang
2021년 5월 24일
a=[1 2 3;0 0 0 ; 1 0 2];
index=all(a==0,2);
a(index,:)=[];
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!