Extracting matrix from a matrix based with condition
显示 更早的评论
How can I extract matrix from matrix with condition for value in column? I have matrix A [6x6] and I need get matrix B,which value of column num.6 is more than 2 and less than 7.
A=[4, 5, 6, 2, 7, 3; 8, 9, 5, 4, 5, 1; 4, 5, 6, 2, 7, 9; 8, 9, 5, 4, 5, 8; 8, 1, 1, 1, 1, 2; 5, 6, 2, 2, 4, 6]
Answer will be: B=[4, 5, 6, 2, 7, 3; 5, 6, 2, 2, 4, 6]
回答(1 个)
Guillaume
2017-1-3
B = A(A(:, 2)>2 & A(:, 2)<7, :)
which shows that your example answer is missing a row.
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!