MATLAB Answers

0

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

Asked by Solmaz Kahourzade on 7 Mar 2018
Latest activity Commented on by Solmaz Kahourzade on 8 Mar 2018
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?

  0 Comments

Sign in to comment.

1 Answer

Answer by Guillaume
on 7 Mar 2018
 Accepted Answer

"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)]

  1 Comment

Sign in to comment.