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

4 Ansichten (letzte 30 Tage)
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?

Akzeptierte Antwort

Guillaume
Guillaume am 7 Mär. 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)]

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by