Removing rows in matrix that contain zeros
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Image Analyst
2020-5-2
Try this:
rowsWithZeros = any(A == 0, 2);
A = A(~rowsWithZeros, :);
3 个评论
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, :)
更多回答(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!