How to find minimum number in matrix and form a new matrix based on that
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Image Analyst
2017-2-17
If you have the Statistics and Machine Learning Toolbox (type ver to find out), then use grpstats():
B = grpstats(A, A(:, 1), 'min')
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!