How to swap elements of the first column of the S matrix with the first line elements?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ricardas Gudonavicius
am 16 Mai 2018
Kommentiert: Ricardas Gudonavicius
am 17 Mai 2018
Hi I have a matrix
A=[1 2 3;
4 5 6;
7 8 9]
but I want to switch the first column with first line like this
A=[1 4 7;
2 5 6;
3 8 9].
What it's the fast way to do it? Any help is appreciated! Thank you
0 Kommentare
Akzeptierte Antwort
James Tursa
am 16 Mai 2018
If only the 1st column and row are involved, e.g. a simple swap:
A1 = A(:,1);
A(:,1) = A(1,:);
A(1,:) = A1;
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices 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!