Extracting matrix from a matrix based with condition
Show older comments
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]
Answers (1)
Guillaume
on 3 Jan 2017
B = A(A(:, 2)>2 & A(:, 2)<7, :)
which shows that your example answer is missing a row.
1 Comment
Uladzislau Ivaniuk
on 4 Jan 2017
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!