How this code works and why for? What action does this code take?
Ältere Kommentare anzeigen
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 Kommentar
Rena Berman
am 12 Okt. 2020
(Answers Dev) Restored edit
Antworten (1)
James Tursa
am 17 Jun. 2020
1 Stimme
You could look here:
3 Kommentare
Alex McQueen
am 17 Jun. 2020
madhan ravi
am 17 Jun. 2020
xD it is.
Alex McQueen
am 17 Jun. 2020
Kategorien
Mehr zu Get Started with MATLAB finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!