Deleting repeated values in 2 matrices
Show older comments
Heya so I have a 22*2 and 25*2 matrix and I want to delete rows on both of them that have the same value on the 2nd column. So if theres say 1.25 on row 6 of A and 1.25 on row 8 of B is it possible to detect this and delete both rows?
Answers (2)
Dyuman Joshi
on 31 Mar 2023
%logical indexing, use tolerance to compare floating point numbers
idx1 = abs(y1(:,2)-1.25)<1e-4);
idx2 = abs(y2(:,2)-1.25)<1e-4);
%deletion
y1(idx1,:)=[];
y2(idx2,:)=[];
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!