How to find minimum number in matrix and form a new matrix based on that
1 view (last 30 days)
Show older comments
Suppose matrix A is as follows:
A = [14 478
14 668
14 708
14 1143
18 468
18 653
18 718
18 813
23 378
23 393
23 573
23 588
23 663
23 743
23 873
24 333
24 338
24 858
26 373
26 408
26 423
26 433
26 438
26 468
26 473
26 663
26 713
26 983];
First column is unique ID, I want to form matrix B in the way that include the minimum number belong to every ID.
B = [14 478
18 468
23 378
24 333
26 373];
0 Comments
Answers (1)
Image Analyst
on 17 Feb 2017
If you have the Statistics and Machine Learning Toolbox (type ver to find out), then use grpstats():
B = grpstats(A, A(:, 1), 'min')
0 Comments
See Also
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!