How to select between duplicated non-integer values of a matrix

3 views (last 30 days)
A= [10.01 5.02;15.20 6.01;14.05 7.12;14.05 5.14;13.5 9.11] I need to find equal number in first column and find the minimum of the corresponding second column. [14.05 5.12] Then create a new matrix as: B= [10.01 5;15.20 6;14.05 5;13.5 9]
But I cannot use “accumarray” as my values are not integer. Would you please guide me?

Accepted Answer

Guillaume
Guillaume on 7 Mar 2018
"But I cannot use “accumarray” as my values are not integer." So what?
[values, ~, subs] = unique(A(:, 1));
B = [values, accumarray(subs, A(:, 2), [], @min)]

More Answers (0)

Categories

Find more on Matrices and Arrays 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!