how sort just nonzero values?
7 次查看(过去 30 天)
显示 更早的评论
how can sort values except zero values i.e i want to sort just non zero values in c. how do that. c=[8 4 5 1 0 0 0 ];
thanks
0 个评论
采纳的回答
Honglei Chen
2012-3-12
Do you want to keep all zeros at the original location? If so
c = [8 4 5 1 0 0 0];
c(c~=0) = sort(c(c~=0));
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!