Info
This question is closed. Reopen it to edit or answer.
For an nx3 matrix, filter out the rows with a maximum 3rd column when the first and second are the same
1 view (last 30 days)
Show older comments
For a matrix such as:
mat=[0 0 0
1 1 2
1 1 3
1 1 5
2 1 6
3 3 2
3 3 1]
Is there a way to filter this matrix to obtain the following matrix
final=[0 0 0
1 1 5
2 1 6
3 3 2]
Appreciate any help thanks
0 Comments
Answers (1)
madhan ravi
on 21 Apr 2019
See if this does what you want:
m=[ 0 0 0
1 1 2
1 1 3
1 1 5
2 1 6
3 3 2
3 3 1 ];
T=array2table(m);
T1=varfun(@max,T,'GroupingVariables',{'m1','m2'});
Final = table2array(T1(:,[1:2,end]))
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!