arrange indices
1 次查看(过去 30 天)
显示 更早的评论
hi, if i have this vector
r=[2 4 18 5 6 15 3 4 16]; i need arrange index 3,6,9 with ascending, and each both previous index are arranged according for that as:
r=[5 6 15 3 4 16 2 4 18]; i.e just 3,6,.....are arranged with ascending and the index befor it are arranged according to third , sixth,..... i would to say ,this is just example i have too long vector
0 个评论
采纳的回答
Andrei Bobrov
2012-4-28
[ii,ii] = sort(r(3:3:end));
out = reshape(r(bsxfun(@plus,ii*3,(-2:0)')),1,[]);
OR:
out = reshape(sortrows(reshape(r,3,[])',3)',1,[]);
7 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!