unique values from from two column
Show older comments
I have a matrix
A=[1 2 3;
2 4 6;
5 3 2;
8 5 4;
6 7 8]
from this matrix, i want that value in first and second column will not get repeated. For eg. in 1st row 2 is in second column and in second row 2 is in 1st column. Please tell me how we can compare these two rows based on first two column and can get only that row whose value in the third column is greater.
Eg:
Output = [ 2 4 6;
8 5 4;
6 7 8]
Only two column (1, 2) will be compared to get the value from third column.
2 Comments
the cyclist
on 31 Aug 2019
Edited: the cyclist
on 31 Aug 2019
Are you guaranteed that there will be at most two rows with equal values, as in your example? Or could it be like this ...
A=[1 2 3;
2 4 6;
5 2 7]
or like this ...
A=[1 2 3;
2 4 6;
5 2 7;
2 5 4]
Could you have a pattern that connects different rows, like this ...
A=[1 2 3;
2 5 6;
5 1 7]
(note that the 2 and the 5 commingle different rows) or like this ...
A=[5 2 3;
2 5 6]
Could you have equal values in the third column?
A = [1 2 6;
2 5 6];
Which row(s) should be kept?
Anu Sharma
on 31 Aug 2019
Accepted Answer
More Answers (0)
Categories
Find more on Operators and Elementary Operations 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!