Retrieving the elements of a matrix with negated exact indexing with index matrix?

只谈情不闲聊 提交于 2019-12-01 11:37:58

go for

  idx = logical(ones(size(A)));   % // all indices here

or, as @Gunther Struyf suggests,

  idx = true(size(A));

then

  idx(I) = 0;                       % // excluding not desired indices    
  B = A(idx);                       % // selection

Alternatively

 B = A;
 B(I) = [];

You can also make use of setdiff to exclude indices. Here's a one-liner for you:

B = A(setdiff(1:numel(A), I))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!