How this code works and why for? What action does this code take?
이전 댓글 표시
A = [11 9 2 47 13 8 9 12];
for i=1:length(A)-1
for j = 2:length(A)
if (A(j-1)> A(j))
temp = A(j-1);
A(j-1) = A(j);
A(j) = temp;
end
end
end
Like given, it is an A vector. And temp is a variable name. It used to calculate sth but it does not tell us what.
I could not get what this code is using for. Can anyone explain it?
댓글 수: 1
Rena Berman
2020년 10월 12일
(Answers Dev) Restored edit
답변 (1개)
James Tursa
2020년 6월 17일
1 개 추천
You could look here:
카테고리
도움말 센터 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!