How to extract parts of an array by given logical conditions?
4 次查看(过去 30 天)
显示 更早的评论
Hi, I have an array, let's say
M=
1 1 0
1 2 0
1 3 1
2 1 0
2 2 1
2 3 1
and I would like to create a new array only with the case for which the value of the third column equals 1. Thus
N=
1 3 1
2 2 1
2 3 1
0 个评论
采纳的回答
Image Analyst
2014-6-9
Try this:
M=[...
1 1 0
1 2 0
1 3 1
2 1 0
2 2 1
2 3 1]
rowsToExtract = M(:,3)==1;
N = M(rowsToExtract,:)
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!