Home > Mobile >  Removing rows by index from arrays in matlab [duplicate]
Removing rows by index from arrays in matlab [duplicate]

Time:09-17

I have an array 2500*30 elements (its type is "single") and I need to remove several rows that I know the index. For example:

duplicate_ids = [1,4:8,11,859,866,1673,2157,2187,2188,2194,2195];

How can I do that? My preference is that to not write a for loop, since I might make mistake (when removing previous row, the index of next rows will change in each rotation).

Thanks in advance

CodePudding user response:

Unfortunately I don't have a valid license at the moment so I cannot test it to make sure it works, but based on the documentation on row-removal, I believe you could do it that way:

mat(duplicate_ids, :) = [];
  • Related