Delete all repeating values in a column and the rest of the matrix's row also
1 view (last 30 days)
Show older comments
Hi guys,
I'm currently working on an event study for a personnal project.
I have a N X 2 matrix.
I would like to be able to, when there is a repeating value in column 1, to delete the entire row associated to this repeating value (So delete repeating value in column 1 and also the corresponding value in column 2).
I would like if possible to have an answer without using the unique fonction... I've tried several codes and possibilities with the unique function, but for an unkown reason the unique function doesn't seem to work on my computer with matlab.
Thank you very much for your time and answer,
Julien
1 Comment
Matt Kindig
on 10 Feb 2014
For repeated values in column 1, do you need to delete all rows which are repeated, or leave behind the first unique row? In other words, which be correct?
%sample data
A = [5, 8, 10, 4;
1, 0, 1, 2;
2, 1, 8, 3;
3, 7, 6, -1;
1, 0, 3, 2];
%is this correct?
B = [5, 8, 10, 4;
2, 1, 8, 3;
3, 7, 6, -1]; %both rows 2 and 5 are removed
%or is this correct?
C = [5, 8, 10, 4;
1, 0, 1, 2;
2, 1, 8, 3;
3, 7, 6, -1]; %just row 5 is removed
Answers (0)
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!