フィルターのクリア

Removing rows in matrix that contain zeros

2 ビュー (過去 30 日間)
Taylor Swaim
Taylor Swaim 2020 年 5 月 2 日
コメント済み: Taylor Swaim 2020 年 5 月 2 日
Here is my code:
A = dmlread('B00001'.txt', '', 1,0)
for k=2:100;
A=A+dmlread(['B00',sprintf('%03d.txt',k)], '',1,0);
end
A=A/100
Right now it reads txt files B00001 to B00100, puts them in a matrix, and averages them to make a new matrix of the same size. But i need to remove the rows that contain zeros.

採用された回答

Image Analyst
Image Analyst 2020 年 5 月 2 日
Try this:
rowsWithZeros = any(A == 0, 2);
A = A(~rowsWithZeros, :);
  3 件のコメント
Image Analyst
Image Analyst 2020 年 5 月 2 日
This seem to work fine:
A = randi([0, 9], 7, 10) % Sample data
rowsWithZeros = any(A == 0, 2);
A = A(~rowsWithZeros, :)
Taylor Swaim
Taylor Swaim 2020 年 5 月 2 日
Yes, thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by