Swap the First and Last Column (CODY)

3 Ansichten (letzte 30 Tage)
Saviyo Therattil
Saviyo Therattil am 7 Jun. 2021
Beantwortet: KSSV am 7 Jun. 2021
function B = swap_ends(A)
X = A(:,end);
C = A(:,1);
A(:,1) = X;
A(:,end) = C;
B = A;
end
How do I reduce it into a length of 7? (Top length is 7).

Antworten (1)

KSSV
KSSV am 7 Jun. 2021
A = rand(1,5) ;
A([1 end]) = A([end 1])

Kategorien

Mehr zu Graph and Network Algorithms finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by