How this code works and why for? What action does this code take?

1 次查看(过去 30 天)
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 个)

James Tursa
James Tursa 2020-6-17

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

标签

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by