A question about ismember function
Show older comments
Suppose I have a matrix
M=[1 1 1; 1 1 1; 0 1 0; 5 5 5; 9 1 8; 5 5 5]; D=[1 1 1; 5 5 5; 9 1 8];
I=ismember(M,D,'rows');
I want to assign a number 1 to rows in M that are in D and 0 to rows in M that are not in D then, remove from M all the rows that crossponds to 1.
The answer is
I= [1 1 0 1 1 1]'
so I want to remove row in M that crossponds to 1 so I type
M(I,:)=[];
It gives M=[0 1 0]; which is the required.
My question is this correct for all problems of this kind?
what is the meaning of M(I,:) ? is not I a vector, how can we type M(vector,:) ? I mean I understand the command M(2,:) for example it means get me the second row in M but what is the meaning of M(vector,:)?
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing 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!