How to delect the zero values in table
    11 ビュー (過去 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!


