sort an array without using the command sort
显示 更早的评论
function sortvector(v)
v1=zeros(1,length(v));
for i=1:length(v)
v1(i)=min(v);
v(find(v==v1(i)))=[];
end
disp(v1)
end
the question was to sort an array without using the command sort. My method was to extract the minimums one by one and put blanks into the elements extracted. However this did not work. What's wrong with this function?
Correction of this method and other methods would help. Thanks.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 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!