matlab - Finding elements in an array other than given indices -


i want find elements in array not given index elements. example, given array a = [1 5 7 8], , index ind = [2 3], operation should return elements [1 8].

use direct index vector:

b = a(setdiff(1:numel(a),ind)); 

or throw away unneeded elements:

b = a; b(ind) = []; 

or use logical indexing:

% either b = a(~any(bsxfun(@eq,ind(:),1:numel(a)),1)); % or b = a(all(bsxfun(@ne,ind(:),1:numel(a)),1)); 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -