corresponding elements of a setdiff of another variable
1 次查看(过去 30 天)
显示 更早的评论
Hello, I have a question about setdiff. I have three variables X ,Y, p. I need to find elements of Y excluding elements of p and corresponding elements of X (corresponding to Y). I ran the following (Both X and Y have same number of elements).
y=setdiff(Y,p);
x= X(setdiff(Y,p)); this doesn't work. Any solutions?
Thanks,
Bharat
0 个评论
采纳的回答
Andrei Bobrov
2015-7-14
编辑:Andrei Bobrov
2015-7-14
x = X(~ismember(Y,p));
or
[~,ii] = setdiff(Y,p);
x = X(ii);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!