How do I insert a column with zeros in the second column of a mxn matrix?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
SAI KRISHNA CHADA
am 10 Nov. 2017
Kommentiert: SAI KRISHNA CHADA
am 10 Nov. 2017
Hello, I would like to insert a column with zeros in the second column of a (mxn) matrix, after which the matrix would be a mx(n+1) matrix. It would be really grateful, if someone could help me on this. Thank you.
0 Kommentare
Akzeptierte Antwort
Mischa Kim
am 10 Nov. 2017
Bearbeitet: Mischa Kim
am 10 Nov. 2017
Brute force:
A = [1 2 3; 4 5 6; 7 8 9]
A = [zeros(size(A,1),1) A];
A(:,[1 2]) = A(:,[2 1])
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Cell Arrays 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!