i have big matrix , want delete rows of indexes in vector v. vector unsorted code below won't work
for i=1:length(v) a(v(i))=[] end
the problem when example row 2 deleted, , next want delete row 4, delete row 5 instead, cause index of row 5 4. think possible sort v descending , delete above sorting time consuming. there other task?
you need pass entire vector of indices delete.
matlab supports powerful indexing features, , learning them simplify writing code , make them less error-prone.
sample code
% delete rows row indices in v a(v, :) = []
Comments
Post a Comment