How to store values of rows in a matrix where the 3rd column is a multiple of 100?
1 次查看(过去 30 天)
显示 更早的评论
I have a matrix with 3 columns and a large number of rows. In order to reduce the rows, I need to keep the rows whose 3rd column value is a multiple of 100 and store it in as a new matrix. How do I do that?
0 个评论
采纳的回答
Ameer Hamza
2020-12-5
编辑:Ameer Hamza
2020-12-5
Use can use rem() to filter the rows where the third column is multiple of 100 and then use logical indexing
M; % nx3 matrix
idx = rem(M(:,3),100)==0;
M_new = M(idx, :);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!