How to filter rows with respect to specific entry?
12 views (last 30 days)
Show older comments
I have thousands of rows and I want to filter those rows in which the entry at third position is three
For example
A=[1 2 3 4 5 6 7 8 9;0 1 2 3 4 5 6 7 8 9 10;5 6 3 2 1 4 7 8 9];
I want the resulting matrix
AA=[1 2 3 4 5 6 7 8 9;5 6 3 2 1 4 7 8 9]
Thanks
1 Comment
dpb
on 10 Mar 2018
>> A=[1 2 3 4 5 6 7 8 9;0 1 2 3 4 5 6 7 8 9 10;5 6 3 2 1 4 7 8 9];
Dimensions of matrices being concatenated are not consistent.
>>
Accepted Answer
dpb
on 10 Mar 2018
>> A=[1 2 3 4 5;0 1 2 3 4;5 6 3 2 1];
>> A(A(:,3)==3,:)
ans =
1 2 3 4 5
5 6 3 2 1
>>
More Answers (0)
See Also
Categories
Find more on Multidimensional Arrays 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!