Deleting repeated values in 2 matrices
4 views (last 30 days)
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?
0 Comments
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,:)=[];
0 Comments
See Also
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!