Traversing through a matrix row by row extracting elements from mimimum to maximum values in each row
1 次查看(过去 30 天)
显示 更早的评论
I have a matrix 1000x6 and want to go through each row elements from min to max order as below:
Columns 1 through 5
0.592128412629931 17.0328745042388 7.80797504750628 2.62020782562556 1.43548900176002
7.70611478980228 18.2818027853596 8.55499281480929 11.2270196387823 10.0060429058785
11.1494174009673 21.4056872109407 11.4261074945239 15.7693095114145 12.041994367597
11.7455399739892 21.5579262590289 16.2448025417738 22.3080196456516 12.9307080813381
16.1940849940913 22.8583802772591 28.1474408671353 23.7985917372857 13.5205777727122
Column 6
2.59409159128796
6.2186461977726
8.7886056470611
22.6010592652641
23.2648494555368
I have this command but it can only give me min value per row. How can I get next higher value in a loop?
>> min(arrival_schedule(1:10,:),[],2)
ans =
0.592128412629931
6.2186461977726
8.7886056470611
11.7455399739892
13.5205777727122
15.5331848959514
16.3512299443613
16.5525102572458
17.4860712673065
20.5693257283949
0 个评论
采纳的回答
madhan ravi
2019-5-11
mink(arrival_schedule(1:10,:),2,2)
% ^ n number of minimum elements
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!