My main dataset is a 65358x31 table, with the first column being an ID number for a particular test subject and the rest of the columns numerical attributes of that subject (e.g, size, area). There are about 2000 test subjects that are invalid and should be removed from the table. The ID numbers corresponding to the invalid test subjects are saved in a separate 2000x1 table. How can I find the rows that correspond to the ID number of invalid test subjects and remove them from the main dataset?
I have been able to use "find" in matlab to remove the invalid rows one by one but since the dataset is large I would like to do this in a more systematic fashion. Thank you in advance for your input.
CodePudding user response:
the correct way is to use a for loop :
for i=1:2000
I=find(data(:,1)==invalid_data(i));
data(I,:)=[];
end
also there is another way but it creates a large matrix in the memory:
[I,~]=find(data(:,1)==invalid_data');
data(I,:)=[];